Aller au contenu

Connexion Windows/nas Par Paire De Cl

Featured Replies

Posté(e)

Bonjour à tous !!!

Depuis hier je tente de me connecter à partir de mon pc windows 7 64bits à mon nas Syno 1010+ (DSM 4.3) par l'intermédiaire de Putty.

Voilà ce que j'ai fait mais sans succès pour li'nstant ;)

Coté pc windows :

J'ai généré une clé privé avec PuttyGen. J'ai enregistré la clé privé sur mon pc dans un dossier sous la forme d'un fichier ppk.

Dans Putty, sous la rubrique connections/data j'ai saisi le nom du compte ssh (en l'occurence admin) ; ensuite dans la rubrique connection/SSH/Auth j'ai ajouté mon fichier de clé privé dans la rubrique Authentification parameters.

Coté nas synology :

Dans /volume1/homes/admin j'ai créer un dossier .ssh qui contient un fichier nommé authorized_keys. Dans ce fichier authorized_keys j'ai copié coller le contenu de la clé généré par puttygen.

Pour les droits sur le dossier .ssh j'ai :

drwx------ 2 root root 4096 Dec 4 17:29 .ssh
Pour les droits sur le fichier authorized_keys j'ai :

-rw-r--r-- 1 root root 398 Dec 4 17:29 authorized_keys

J'ai configuré le fichier /etc/ssh/sshd_config avec les éléments suivants :

PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

PasswordAuthentication no
AllowTcpForwarding yes



Lorsque je lance la connection ssh avec putty j'ai la fenêtre suivante qui apparait et qui me demande le mot de passe du compte admin :

Using username "admin".
Server refused our key
admin@adresse_ip_'s password:

Avez-vous déjà rencontré cette erreur et comment avez vous reussi à la contourner pour vous loguer en ssh par clé sur le syno ?

Merci pour vos lumières !!

Posté(e)

Salut

Tu as redémarré le process sshd ?

Ton compte admin. est autorisée à se connecte en ssh ?

Modifié par Vinky

Posté(e)
  • Auteur

salut,

oui a travers l'interface web du syno j'ai décoché la case "activer le service SSH" puis recocher la case.

Pour info mon fichier de conf /etc/ssh/sshd_config :

# $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

#AllowAgentForwarding yes
AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
ChrootDirectory none
#ChrootDirectory /var/services/homes/%u
#DenyUsers admin

# no default banner path
#Banner none

# override default of no subsystems
#Subsystem sftp /usr/libexec/sftp-server
#Subsystem sftp internal-sftp -f DAEMON -l VERBOSE -u 000
Subsystem sftp internal-sftp -f DAEMON -u 000
#Subsystem sftp /usr/syno/sbin/sftp-server -l DEBUG3

# the following are HPN related configuration options
# tcp receive buffer polling. disable in non autotuning kernels
#TcpRcvBufPoll yes

# allow the use of the none cipher
#NoneEnabled no

# disable hpn performance boosts.
#HPNDisabled no

# buffer size for hpn to non-hpn connections
#HPNBufferSize 2048


# Example of overriding settings on a per-user basis
Match User root
# X11Forwarding no
AllowTcpForwarding yes
# ForceCommand cvs server


Je ne vois ou est le pb pour l'instant :)

Posté(e)

En ssh c'est le compte "root" qu'il faut utiliser a la place d'admin (aucun autre compte n'est autorisé en ssh par défaut: le champ shell dans /etc/passwd est "nologin")

"admin" n'est un compte privilégié uniquement quand utilisé pour se connecter via l'interface Http DSM. En login terminal shell, c'est un compte comme les autres.

Si besoin est, faut savoir que DSM synchronise le mot de passe "root" avec le mot de passe "admin"

En outre, je ne pense pas que les modifications de config sshd soit nécessaires (et surtout le "PasswordAuthentication no" est risqué si tu perd ta clé, mais tu auras l'option d'activer telnet provisoirement en secours cependant).

Modifié par CoolRaoul

Posté(e)
  • Auteur

salut,

je viens de trouver la solution que je vous indiquer donc :

en fait j'ai crée le dossier /.ssh dans le dossier /root/ et non pas dans /volume1/homes/admin/

J'ai fait un chmod 700 sur ce dossier .ssh

J'ai crée un fichier authorized_keys dans le dossier /.ssh

J'ai fait un chmod 644 sur ce fichier.

Enfin j'ai modifier le fichier /etc/ssh/sshd_config avec ces 3 paramètres :

PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys

PasswordAuthentication yes

Voilà si ca peut aider d'autres personnes à se connecter par clé sur le syno.

Est ce que vous conseiller de ne pas utiliser root ?

Posté(e)

Enfin j'ai modifier le fichier /etc/ssh/sshd_config avec ces 3 paramètres :

PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys

PasswordAuthentication yes

Pourquoi ces modifs ? (d'autant plus que les 2 premières options sont celles par défaut de sshd)

Est ce que vous conseiller de ne pas utiliser root ?

Ca dépend,tu ne nous as pas expliqué ce que tu voulais faire en connection ssh déja.

Rejoindre la conversation

Vous pouvez publier maintenant et vous inscrire plus tard. Si vous avez un compte, connectez-vous maintenant pour publier avec votre compte.

Invité
Répondre à ce sujet…

Information importante

Nous avons placé des cookies sur votre appareil pour aider à améliorer ce site. Vous pouvez choisir d’ajuster vos paramètres de cookie, sinon nous supposerons que vous êtes d’accord pour continuer.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.