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 17/07/2020, à 09:01

JujuLand

[Resolu] Service ssh

Bonjour,
Je viens d'installer un portable en Xubuntu 18.04 (cest le premier en 18.04), et j'ai paramétré le ssh, comme je le faisais précedemment.
Lors d'une tentative de connexion, j'ai eu un refus de connexion.

Ce matin en redémarrant l'ordi, j'ai le service ssh qui est bien démarré, mais impossible de voir le statut ou de me connecter ...

anais@anais-Lenovo:~$ ping $(hostname)
PING anais-Lenovo (127.0.1.1) 56(84) bytes of data.
64 bytes from anais-Lenovo (127.0.1.1): icmp_seq=1 ttl=64 time=0.043 ms
64 bytes from anais-Lenovo (127.0.1.1): icmp_seq=2 ttl=64 time=0.070 ms
^C
--- anais-Lenovo ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1013ms
rtt min/avg/max/mdev = 0.043/0.056/0.070/0.015 ms
anais@anais-Lenovo:~$ sudo ssh service status
[sudo] Mot de passe de anais : 
ssh: Could not resolve hostname service: Temporary failure in name resolution
anais@anais-Lenovo:~$ 

Si quelqu'un a une idée ... je patauge !!!
Merci
A+

Dernière modification par JujuLand (Le 17/07/2020, à 19:08)


Xubuntu 16.04 > Dell DM061 (2007) + Dell Inspiron 531 (2008)
Xubuntu 16.04 > Asus X51L (2009) + MSI GX723 (2009)
Xubuntu 22.04 > HP 15BA048NF (2018)

Hors ligne

#2 Le 17/07/2020, à 12:30

lann

Re : [Resolu] Service ssh

Pour le status du service ssh

systemctl status ssh

Hors ligne

#3 Le 17/07/2020, à 13:54

JujuLand

Re : [Resolu] Service ssh

systemctl ne fait que confirmer que le service tourne, mais quid du message d'erreur lorsque je veux me connecter ...

anais@anais-Lenovo:/etc/exim4$ systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
   Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enab
   Active: active (running) since Fri 2020-07-17 09:33:53 CEST; 5h 18min ago
  Process: 1480 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCES
  Process: 1475 ExecReload=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
  Process: 773 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
 Main PID: 789 (sshd)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/ssh.service
           └─789 /usr/sbin/sshd -D

juil. 17 09:34:00 anais-Lenovo systemd[1]: Reloading OpenBSD Secure Shell server
juil. 17 09:34:00 anais-Lenovo sshd[789]: Received SIGHUP; restarting.
juil. 17 09:34:00 anais-Lenovo systemd[1]: Reloaded OpenBSD Secure Shell server.
juil. 17 09:34:00 anais-Lenovo sshd[789]: Server listening on 0.0.0.0 port 22461
juil. 17 09:34:00 anais-Lenovo sshd[789]: Server listening on :: port 22461.
juil. 17 09:34:00 anais-Lenovo systemd[1]: Reloading OpenBSD Secure Shell server
juil. 17 09:34:00 anais-Lenovo sshd[789]: Received SIGHUP; restarting.
juil. 17 09:34:00 anais-Lenovo systemd[1]: Reloaded OpenBSD Secure Shell server.
juil. 17 09:34:00 anais-Lenovo sshd[789]: Server listening on 0.0.0.0 port 22461
juil. 17 09:34:00 anais-Lenovo sshd[789]: Server listening on :: port 22461.
lines 1-21/21 (END)

Xubuntu 16.04 > Dell DM061 (2007) + Dell Inspiron 531 (2008)
Xubuntu 16.04 > Asus X51L (2009) + MSI GX723 (2009)
Xubuntu 22.04 > HP 15BA048NF (2018)

Hors ligne

#4 Le 17/07/2020, à 14:29

bruno

Re : [Resolu] Service ssh

Modération : déplacé en section serveur

Côte serveur cela semble fonctionner. Il faut que tu indiques la commande lancée sur le client et son retour complet.

Hors ligne

#5 Le 17/07/2020, à 15:13

JujuLand

Re : [Resolu] Service ssh

Bon, je viens d'autoriser la connexion par mot de passe, et ça fonctionne
Donc ça vient de la clé ou du paramétrage ...
Au départ, j'avais simplement créé la clé avec ssh-keygen, la connexion ne passait pas
Ensuite, j'ai fait un ssh-add, toujours pareil ...

Donc la clé semble ok, et ça vient probablement du paramétrage .. il y a des paramètres qui sont nouveaux depuis la 16.04, et je ne maitrise pas trop ...
Quand je n'autorise pas la connexion par mot de passe, j'ai ça:

anais@anais-Lenovo:~$ ssh -p 22461 anais@192.168.1.30 -v
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 192.168.1.30 [192.168.1.30] port 22461.
debug1: Connection established.
debug1: identity file /home/anais/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/anais/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/anais/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/anais/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/anais/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/anais/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/anais/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/anais/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.1.30:22461 as 'anais'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:+Ov2bz4PgulpRiNX30N0YfDLbZJo3tvfC/zN3s7s2tg
debug1: Host '[192.168.1.30]:22461' is known and matches the ECDSA host key.
debug1: Found key in /home/anais/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:xRwDhtvIGElr86jd28S3oBKM3Nbdt6QhOaNWoHHBXt0 /home/anais/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering public key: RSA SHA256:JccE/SUty4P2F/4AO2KfZYJ/InqKzP3MqHtxwQuMwQs anais@anais-Lenovo
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/anais/.ssh/id_dsa
debug1: Trying private key: /home/anais/.ssh/id_ecdsa
debug1: Trying private key: /home/anais/.ssh/id_ed25519
debug1: No more authentication methods to try.
anais@192.168.1.30: Permission denied (publickey).

Voici le sshd_config

anais@anais-Lenovo:~/.ssh$ cat /etc/ssh/sshd_config
#	$OpenBSD: sshd_config,v 1.101 2017/03/14 07:19:07 djm 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 override the
# default value.

Port 22461
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

PubkeyAuthentication yes

# Expect .ssh/authorized_keys2 to be disregarded by default in future.
AuthorizedKeysFile	%h/ssh/authorized_keys
# .ssh/authorized_keys2

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# 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 yes
#PermitEmptyPasswords no

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

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

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# 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

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

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

# override default of no subsystems
Subsystem	sftp	/usr/lib/openssh/sftp-server

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

Dernière modification par JujuLand (Le 17/07/2020, à 15:22)


Xubuntu 16.04 > Dell DM061 (2007) + Dell Inspiron 531 (2008)
Xubuntu 16.04 > Asus X51L (2009) + MSI GX723 (2009)
Xubuntu 22.04 > HP 15BA048NF (2018)

Hors ligne

#6 Le 17/07/2020, à 15:20

bruno

Re : [Resolu] Service ssh

Ta configuration su serveur SSH est celle par défaut au numéro de port près.
Expliques en détail ce que tu fais pour générer les clés, les copier sur le serveur et donne les retours complets des commandes.

D'après ton retour que tu viens de modifier, le serveur n'arrive pas à faire la correspondance entre la clé privée sur le client dans /home/anais/.ssh/id_rsa et une clé publique présente sur le serveur.

Vérifie sur le serveur dans /home/anais/.ssh/authorized_keys que ta clé publique est bien présente.

Dernière modification par bruno (Le 17/07/2020, à 15:31)

Hors ligne

#7 Le 17/07/2020, à 15:44

JujuLand

Re : [Resolu] Service ssh

Oui, à part 3 params :
- Port 22461
- PasswordAuthentication No
- UsePAM no

J'ai effacé la clé, et recréé:

anais@anais-Lenovo:~/.ssh$ rm id*
anais@anais-Lenovo:~/.ssh$ rm known_hosts 
anais@anais-Lenovo:~/.ssh$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/anais/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/anais/.ssh/id_rsa.
Your public key has been saved in /home/anais/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:bnYG6etrcGXZp6M9JM8KFuxbn+VFlNEkFSrc1NnHGdw anais@anais-Lenovo
The key's randomart image is:
+---[RSA 2048]----+
|             .+B@|
|          . o .*E|
|           = o .o|
|       . .+ o .. |
|        So   o  .|
|      .+.o. +  . |
|       oO +B .. .|
|       +.B..=+ . |
|       o=...o..  |
+----[SHA256]-----+
anais@anais-Lenovo:~/.ssh$ cat id*pub >> authorized_keys 
anais@anais-Lenovo:~/.ssh$ sudo service ssh restart
anais@anais-Lenovo:~/.ssh$ ssh -p 22461 anais@192.168.1.30
The authenticity of host '[192.168.1.30]:22461 ([192.168.1.30]:22461)' can't be established.
ECDSA key fingerprint is SHA256:+Ov2bz4PgulpRiNX30N0YfDLbZJo3tvfC/zN3s7s2tg.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[192.168.1.30]:22461' (ECDSA) to the list of known hosts.
anais@192.168.1.30: Permission denied (publickey).
anais@anais-Lenovo:~/.ssh$ ls -al
total 24
drwx------  2 anais anais 4096 juil. 17 16:34 .
drwxr-xr-x 17 anais anais 4096 juil. 17 14:59 ..
-rw-rw-r--  1 anais anais 2404 juil. 17 16:33 authorized_keys
-rw-------  1 anais anais 1766 juil. 17 16:33 id_rsa
-rw-r--r--  1 anais anais  400 juil. 17 16:33 id_rsa.pub
-rw-r--r--  1 anais anais  222 juil. 17 16:34 known_hosts

Merci
A+


Xubuntu 16.04 > Dell DM061 (2007) + Dell Inspiron 531 (2008)
Xubuntu 16.04 > Asus X51L (2009) + MSI GX723 (2009)
Xubuntu 22.04 > HP 15BA048NF (2018)

Hors ligne

#8 Le 17/07/2020, à 15:54

bruno

Re : [Resolu] Service ssh

Mauvaise manip :

cat id*pub >> authorized_keys 

La clé publique doit être copiée sur le serveur pas sur le client !
Pour copier la clé sur le serveur c'est :

ssh-copy-id -p 22461 anais@192.168.1.30

Évidemment pour pouvoir le faire il faut au préalable réactiver la connexion par mot de passe :

PasswordAuthentication yes

Pourquoi UsePAM no ? Et pourquoi changer le port par défaut ?

Hors ligne

#9 Le 17/07/2020, à 16:17

JujuLand

Re : [Resolu] Service ssh

Non, cette copie est faite sur le serveur, regarde bien ...

En fait, je fais toujours un test de connexion ssh du serveur sur le serveur, ça a toujours fonctionné ...

Je n'ai jamais vu l'interet du PAM ...

A+


Xubuntu 16.04 > Dell DM061 (2007) + Dell Inspiron 531 (2008)
Xubuntu 16.04 > Asus X51L (2009) + MSI GX723 (2009)
Xubuntu 22.04 > HP 15BA048NF (2018)

Hors ligne

#10 Le 17/07/2020, à 17:15

bruno

Re : [Resolu] Service ssh

Justement j'ai bien regardé et toutes les commandes sont passées sur la même machine. De toute façon la commande en question est aberrante.

Hors ligne

#11 Le 17/07/2020, à 17:24

JujuLand

Re : [Resolu] Service ssh

L'auto-connexion n'a évidemment aucun interet, mais c'est juste à titre de test, lorsque je paramètre ...
D'habitude la connexion ne pose aucun problème, et là, si. Mais c'est le même problème lorsque je tente de me connecter avec une autre machine ... qui est en enXubuntu 16.04 et avec une version différente de ssh

A+

Dernière modification par JujuLand (Le 17/07/2020, à 17:25)


Xubuntu 16.04 > Dell DM061 (2007) + Dell Inspiron 531 (2008)
Xubuntu 16.04 > Asus X51L (2009) + MSI GX723 (2009)
Xubuntu 22.04 > HP 15BA048NF (2018)

Hors ligne

#12 Le 17/07/2020, à 17:53

bruno

Re : [Resolu] Service ssh

Je n'avais pas compris que tu faisais un test uniquement sur le serveur. Effectivement c'est tordu et n'a aucun intérêt.
Surtout que tu peux faire simplement :

ssh localhost

Compare ta clé publique et le contenu du fichier authorized_keys :

cat ~/.ssh/id_rsa.pub
cat ~/.ssh/authorized_keys

Hors ligne

#13 Le 17/07/2020, à 18:27

JujuLand

Re : [Resolu] Service ssh

connexion avec password

anais@anais-Lenovo:~$ ssh  -p 22461 localhost
The authenticity of host '[localhost]:22461 ([127.0.0.1]:22461)' can't be established.
ECDSA key fingerprint is SHA256:+Ov2bz4PgulpRiNX30N0YfDLbZJo3tvfC/zN3s7s2tg.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[localhost]:22461' (ECDSA) to the list of known hosts.
anais@localhost's password: 
Permission denied, please try again.
anais@localhost's password: 
Last login: Fri Jul 17 16:47:14 2020 from 192.168.1.24
Cannot open display.
 Info : anais est connecté depuis 19:22 ... mais tranquille
 Lancer le menu maintsys ( o / N)?
 Attention : Vous devez avoir lancé la connexion avec -X
anais@anais-Lenovo:~/.ssh$ cat *.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHxQ8YNspgSax7AW/2M1gZs7q+wvcMUx4JQHpu3gHo1ilF20DO8IatEFGZE0iS81KUwnHgH+vOgf9GpdnbCl1paOyrR1sD6kW5xx6HWVTFOJ3kOOkrVvGR5D/mnhfZ+O3QIhh+1hlhhezs0VtBanYN6XUry312gsJG1NHu8uNg5mnYVzBZmNVrorRFlBh92F0N1zPjfn0ISWpybRq/otSzICzeaUODfFy8MHOwyOcYheqzqgsKDyyFwAGCEzKLtARMFWTPS0xA0MjJYdMkc7DIqPPpRzKgjENQzmg5QLY/CRkq2fclKTkrJmNH4EkpCaJ2WgJ9sh1gkLbRdAIyO2Mz anais@anais-Lenovo
anais@anais-Lenovo:~/.ssh$ cat authorized_keys |grep Lenovo
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHxQ8YNspgSax7AW/2M1gZs7q+wvcMUx4JQHpu3gHo1ilF20DO8IatEFGZE0iS81KUwnHgH+vOgf9GpdnbCl1paOyrR1sD6kW5xx6HWVTFOJ3kOOkrVvGR5D/mnhfZ+O3QIhh+1hlhhezs0VtBanYN6XUry312gsJG1NHu8uNg5mnYVzBZmNVrorRFlBh92F0N1zPjfn0ISWpybRq/otSzICzeaUODfFy8MHOwyOcYheqzqgsKDyyFwAGCEzKLtARMFWTPS0xA0MjJYdMkc7DIqPPpRzKgjENQzmg5QLY/CRkq2fclKTkrJmNH4EkpCaJ2WgJ9sh1gkLbRdAIyO2Mz anais@anais-Lenovo

Je ne vois pas de difference ...
A+


Xubuntu 16.04 > Dell DM061 (2007) + Dell Inspiron 531 (2008)
Xubuntu 16.04 > Asus X51L (2009) + MSI GX723 (2009)
Xubuntu 22.04 > HP 15BA048NF (2018)

Hors ligne

#14 Le 17/07/2020, à 18:41

bruno

Re : [Resolu] Service ssh

Les clés sont bien les mêmes. Je ne vois pas ce qui cloche.
EDIT j'ai trouvé l'erreur :

AuthorizedKeysFile	%h/ssh/authorized_keys

c'est .ssh/authorized_keys, ou mieux : commenter pour laisser la valeur par défaut.

Dernière modification par bruno (Le 17/07/2020, à 18:53)

Hors ligne

#15 Le 17/07/2020, à 19:07

JujuLand

Re : [Resolu] Service ssh

Bien vu ...

En fait, j'avais modifié à l'identique de la version qui tourne sous Xubuntu 16.04.

Erreur !!

Merci
A+


Xubuntu 16.04 > Dell DM061 (2007) + Dell Inspiron 531 (2008)
Xubuntu 16.04 > Asus X51L (2009) + MSI GX723 (2009)
Xubuntu 22.04 > HP 15BA048NF (2018)

Hors ligne