Problème avec mon SSH

Salut tout l’monde

Je viens de créer un nouvel utilisateur afin de pouvoir me connecter pas son biais et éviter root.
en éditant mon fichier SSH, j’ai la ligne pour le port à changer, la ligne PermitRootLogin à changer, mais il me manque la ligne AllowUsers pour indiquer le nouvel utilisateur.

Je ne sais pas comment retrouver cette ligne pour attribuer la valeur de mon utilisateur.

Copie de mon SSH

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# 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
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

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

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile     %h/.ssh/authorized_keys

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

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes

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

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

Bonsoir,

Je ne peux pas t’aider concernant ton problème, mais j’ai édité ton sujet concernant la copie du fichier de configuration.
Quand tu as du code comme c’est le cas ici, il faut le mettre entre balises pour que ce soit lisible, sinon la mise en forme est horrible. Pour faire ça tu tapes ton code, ou tu fais ton copier-coller, puis tu séléctionnes le tout avec la souris et tu cliques sur l’icone " </> " qui apparait dans la boite à message en haut parmi les menus. :wink:

Tu l’ajoutes tout simplement !

Je pense qu’il cherche plutôt la syntaxe exacte de la ligne en question.

Salut,

Précédemment je l’ai ajouté en sus du changement de port et PermitRootLogin no, et je n’ai plus pu atteindre mon serveur. Un RaZ a été nécessaire.
Possible qu’il ait été mal placé.

Edit:
Mon problème est similaire à celui-ci > Connexion ssh autre que root impossible

Le dernier paragraphe est dans ce genre, tu ajoutes bêtement comme indiqué en gras :

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

AllowUsers ricardo

Merci, je vais tester.

Ahhh, … ahhh, bon … comme il nommait l’option en question, je n’avais pas compris qu’il ne savait pas comment l’utiliser !

@calimero: milles excuses … :stuck_out_tongue:
Toute option dans les fichiers ‘ssh’, tu peux les mettre n’importe où tu veux dans le fichier … par contre, un impératif est une par ligne !

Donc, oui :
AllowUsers calimero

En pratique, il n’y a pas besoin de cette ligne AllowUsers
Exemple (connexion sans mot de passe par clés + ssh-agent

fp2x@drhpcmss:~$ fgrep AllowUsers  /etc/ssh/sshd_config
fp2x@drhpcmss:~$ ssh drbuildbot fgrep AllowUsers /etc/ssh/sshd_config
fp2x@drhpcmss:~$ ssh fp2@samlp fgrep AllowUsers /etc/ssh/sshd_config
fp2x@drhpcmss:~$ ssh masime fgrep AllowUsers /etc/ssh/sshd_config
fp2x@drhpcmss:~$

Ceci entre machines Debian, maintenant vers des Ubuntu

fp2x@drhpcmss:~$ ssh fpetitjean@drlouis fgrep AllowUsers /etc/ssh/sshd_config
fp2x@drhpcmss:~$ ssh -p 9114 fpetitjean@drsoseng fgrep AllowUsers /etc/ssh/sshd_config
fp2x@drhpcmss:~$

Même sur un CentOS, on a

[fp2x@stab ~]$ ls -l /etc/ssh/sshd_config
-rw-------. 1 root root 3879 12 mai   06:52 /etc/ssh/sshd_config
[fp2x@stab ~]$ sudo fgrep AllowUsers /etc/ssh/sshd_config
[fp2x@stab ~]$ logout

Il est beaucoup plus simple d’installer le bon fichier authorized_keys au bon endroit ( $HOME/.ssh ) que de bricoler avec ce paramétrage système.

Cordialement,
Regards,
Mit freundlichen Grüßen,
مع تحياتي الخالصة

F. Petitjean

Je vous écris une longue lettre parce que je n’ ai pas le temps d’ en écrire une courte.
– Blaise Pascal

Tout pardonné tu es. Merci pour ton aide