Как настроить ключ SSH на моем сервере
Я пытаюсь настроить пароль для доступа к моему серверу с Ubuntu Server 16.04
Вот что я сделал (извините, комментарии не на английском):
Sécuriser SSH :
Créer 1 administrateur
# adduser admin962
L’ajouter aux groupes sudo et ssh
# adduser admin962 sudo
# adduser admin962 ssh
Modifier la configuration de SSH (interdire root, modifier le port et autoriser uniquement le groupe sudo)
# nano /etc/ssh/sshd_config
AllowGroups sudo
Port 4029
RSAAuthentication yes
PubkeyAuthentication yes
décommenter AuthorizedKeysFile
Redémarrer le service SSH
# service ssh restart
Se déconnecter
# exit
Créer un jeu de clés (clé publique et clé privée) sur le client
$ ssh-keygen -t rsa -b 4096 -C admin962@vps307796
Faire entrée et choisir la passphrase
Copier la clé publique du client sur le serveur
$ ssh-copy-id -i ~/.ssh/id_rsa.pub admin962@vps307796.ovh.net -p 4029
Se connecter avec admin962 et saisir le mot de passe (tester avec une nouvelle fenêtre)
$ ssh admin962@vps307796.ovh.net -p 4029
Droits des dossiers
$ chmod go-w ~/
$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/authorized_keys
$ ssh-add
Recharger le service SSH
$ sudo service sshd reload
Se déconnecter
# exit
Se connecter avec admin962 et saisir la passphrase (tester avec une nouvelle fenêtre)
$ ssh admin962@vps307796.ovh.net -p 4029
Modifier la configuration de SSH (refuser les mots de passe)
$ sudo nano /etc/ssh/sshd_config
PermitRootLogin no
PasswordAuthentication no
UsePAM no
Redémarrer le service SSH
$ service ssh restart
Se connecter avec admin962 et saisir la passphrase
$ ssh admin962@vps307796.ovh.net -p 4029
Следуя приведенным выше инструкциям, при подключении появляется сообщение:
Agent admitted failure to sign using the key.
Permission denied (publickey).
И подробно:
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to vps307796.ovh.net [137.74.174.65] port 4029.
debug1: Connection established.
debug1: identity file /home/phablet/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/phablet/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/phablet/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/phablet/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/phablet/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/phablet/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/phablet/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/phablet/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Ubuntu-5ubuntu1.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr umac-64-etm@openssh.com none
debug1: kex: client->server aes128-ctr umac-64-etm@openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 3f:a2:b6:45:3c:9b:e5:f8:e1:53:fb:fb:8c:21:46:52
debug1: Host 'vps307796.ovh.net' is known and matches the ECDSA host key.
debug1: Found key in /home/phablet/.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/phablet/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 535
Agent admitted failure to sign using the key.
debug1: Offering RSA public key: admin462@vps307796
debug1: Server accepts key: pkalg ssh-rsa blen 535
Agent admitted failure to sign using the key.
debug1: Trying private key: /home/phablet/.ssh/id_dsa
debug1: Trying private key: /home/phablet/.ssh/id_ecdsa
debug1: Trying private key: /home/phablet/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).