Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 21/08/2017, à 18:45

Bensuperpc

Connexion impossible Serveur SSH clés publique "Permission denied (Pub

Bonjour,

Récemment, j'ai créé un serveur SSH sur plusieurs pc, mais ils n’étaient pas sécurisés, j'ai donc configuré un système de clés publique/privé...

Mais quand j'essais de me connecter avec cette commande:

ssh pi@192.168.1.98 -p 1024

J'ai une erreur :

Permission denied (publickey).

lors de ma connexion au serveur...

J'ai suivi ce tutoriel : https://doc.ubuntu-fr.org/ssh#authentif … iqueprivee et fais ces commandes :

sudo chmod 777 ~/*
ssh-copy-id -i ~/.ssh/id_rsa.pub -p 1024 "pi@192.168.1.98"

elle m'a donnée :

usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/bensuperpc/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
pi@192.168.1.98's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh -p '1024' 'pi@192.168.1.98'"
and check to make sure that only the key(s) you wanted were added.

Changer la config :

AuthorizedKeysFile    /home/pi/.ssh/authorized_keys

Il y a aussi Proftpd et Jail2ban qui sont installés

le fichier de config:

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

# What ports, IPs and protocols we listen for
Port 1024
# 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
#without-password
StrictModes no

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 no

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

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# 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

Pourriez-vous m'aider s'il vous plait  smile ,

Dernière modification par Bensuperpc (Le 21/08/2017, à 20:45)

Hors ligne

#2 Le 22/08/2017, à 10:18

Starmate

Re : Connexion impossible Serveur SSH clés publique "Permission denied (Pub

C'est quoi les règles iptables du serveur cible?

Hors ligne

#3 Le 22/08/2017, à 10:59

bruno

Re : Connexion impossible Serveur SSH clés publique "Permission denied (Pub

Bensuperpc a écrit :

J'ai suivi ce tutoriel : https://doc.ubuntu-fr.org/ssh#authentif … iqueprivee et fais ces commandes :

sudo chmod 777 ~/*

Bonjour,

Ce n'est sûrement pas dans le tutoriel que tu as suivi !
As-tu conscience que tu viens de rendre tous les fichiers de ton dossier personnel exécutables et accessibles en lecture et écriture à tout le monde ?
Il y a fort à parier que les droits d'accès excessif sur le dossier .ssh et ses fichiers empêchent le serveur d'accepter la clé privée.

Hors ligne

#4 Le 22/08/2017, à 11:31

michel_04

Re : Connexion impossible Serveur SSH clés publique "Permission denied (Pub

Bonjour,

bruno a écrit :
Bensuperpc a écrit :

J'ai suivi ce tutoriel : https://doc.ubuntu-fr.org/ssh#authentif … iqueprivee et fais ces commandes :

sudo chmod 777 ~/*

Ce n'est sûrement pas dans le tutoriel que tu as suivi !

Hier, en lisant ce post, je n'ai pas voulu croire à ce chmod 777 ~/ trouvé dans la page SSH.
J'ai pensé à une faute de frappe. Même en cherchant bien, on ne trouve que du 700 et du 755 sur cette page.

A+

Hors ligne