Problème d'accès NAS Synology via clef SSH

Bonjour,

J’ai parcouru tous les tutoriels du net afin de réussir à créer une connexion SSH entre mon serveur Debian et mon Nas Synology (par exemple tuto.myhost.fr/synology/38-tutor … sh-par-cle ). Malheureusement, après avoir répété quelques dizaines de fois les opérations, la connexion ne se fait toujours pas, la commande SSH me demande toujours un mot de passe.

Voici le contenu de mon fichier SSH:

#       $OpenBSD: sshd_config,v 1.82 2010/09/06 17:10:19 naddy Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# The default requires explicit activation of protocol 1
Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
MaxAuthTries 6
#MaxSessions 10

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile   .ssh/authorized_keys

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication no
#PermitEmptyPasswords no

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
#UsePAM no

A noter que j’ai testé en décommantant puis en recommantant les lignes:
#PasswordAuthentication no
#PermitEmptyPasswords no

Avec les deux instructions commentées, le résultat de la commande ssh -v -p 25723 thib@monserveur est:

OpenSSH_6.0p1 Debian-4+deb7u1, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 11.22.33.44 [11.22.33.44] port 22.
debug1: Connection established.
debug1: identity file /home/thib/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/thib/.ssh/id_rsa-cert type -1
debug1: identity file /home/thib/.ssh/id_dsa type 2
debug1: Checking blacklist file /usr/share/ssh/blacklist.DSA-1024
debug1: Checking blacklist file /etc/ssh/blacklist.DSA-1024
debug1: identity file /home/thib/.ssh/id_dsa-cert type -1
debug1: identity file /home/thib/.ssh/id_ecdsa type -1
debug1: identity file /home/thib/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.8p1-hpn13v11
debug1: match: OpenSSH_5.8p1-hpn13v11 pat OpenSSH_5*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 8f:8b:69:a2:07:da:b8:56:fb:81:49:c5:18:ae:36:9a
debug1: Host '[11.22.33.44]:22' is known and matches the ECDSA host key.
debug1: Found key in /home/thib/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/thib/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Offering DSA public key: /home/thib/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/thib/.ssh/id_ecdsa
debug1: Next authentication method: password

Avec les deux instructions décommentées, le résultat de la commande ssh -v -p 25723 thib@monserveur est:

debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 11.22.33.44 [11.22.33.44] port 22.
debug1: Connection established.
debug1: identity file /home/thib/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/thib/.ssh/id_rsa-cert type -1
debug1: identity file /home/thib/.ssh/id_dsa type 2
debug1: Checking blacklist file /usr/share/ssh/blacklist.DSA-1024
debug1: Checking blacklist file /etc/ssh/blacklist.DSA-1024
debug1: identity file /home/thib/.ssh/id_dsa-cert type -1
debug1: identity file /home/thib/.ssh/id_ecdsa type -1
debug1: identity file /home/thib/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.8p1-hpn13v11
debug1: match: OpenSSH_5.8p1-hpn13v11 pat OpenSSH_5*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 8f:8b:69:a2:07:da:b8:56:fb:81:49:c5:18:ae:36:9a
debug1: Host '[11.22.33.44]:22' is known and matches the ECDSA host key.
debug1: Found key in /home/thib/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
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/thib/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering DSA public key: /home/thib/.ssh/id_dsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/thib/.ssh/id_ecdsa
debug1: No more authentication methods to try.
Permission denied (publickey).

Ce qui me laisse à penser que c’est un problème de clef. Pourtant j’ai bien généré ma clef, et je l’ai bien copier dans .ssh/authorized_keys en veillant bien à modifier les droits sur le dossier et sur le fichier.

Je sollicite l’aide des experts car j’avoue que je suis un peu bloqué.

Merci par avance pour votre aide.

Thibo

Salut, je fais ça tous les jours ^^ (sauvegarde de mon dédié vers mon NAS).
Et je l’ai configuré encore très récemment avec un VPS.

Voici mes étapes :
-> Mon synology est configuré pour les connexions SSH autres que le root (http://blog.bpardo.fr/article20/synology-donner-facilement-un-acces-ssh-a-un-utilisateur)

-> Je fais à partir de mon serveur la création de clé (ssh-keygen) (sans passphrase si c’est pour exécuter un script avec cron par ex)

-> Je fais la copie de clé vers mon NAS à partir de mon serveur avec la commande ssh-copy-id -i (http://doc.ubuntu-fr.org/ssh partie 3.2)

A aucun moment je n’ai touché aux fichiers de configuration de ssh (serveur…)

En espérant t’avoir aidé.

Merci pour ta réponse Maxdecondé mais imaginons que je veuille plutôt utiliser une synchro automatique entre mon seveur et mon nas, je vais avoir besoin d’utiliser un clef RSA pour que le con ne me demande pas à chaque fois mon mot de passe. C’est donc dans cette problématique que je me trouve, pas dans celle de vouloir faire une copie manuelle de mes fichiers. Je n’ai donc pas besoin d’avoir un terminal actif le temps que la copie se fasse.

Mon accès SSH avec user/pswd fonctionne très bien…

D’ou mon commentaire: sans passphrase lors de la creation de la clé, ainsi la connexion pourra se faire sans intervention humaine. Je n’ai trouvé que ça pour mes scripts de sauvegarde vers mon nas…

Mais je n’avais pas mis de passphrase non plus.

Je viens de suivre le tutoriel de fr.openclassrooms.com/informatiq … ue-par-cle qui est le même que tous les tutoriaux sur le sujet, et ça maintenant ça fonctionne. Par contre je suis incapable d’expliquer ce qui n’allait pas.

Certainement le ssh-copy-id. M’enfin, maintenant ça marche ^^ Un petit coche vert pour montrer que c’est résolu ^^ Bon amusement ^^