Pages : 1
#1 Le 31/10/2017, à 13:52
- McSource
connexion SSH refusé
Bonjour,
Je n'arrive pas à comprendre pourquoi je ne peux pas me connecter en SSH sur ma VM:
ssh 10.33.2.240
ssh: connect to host 10.33.2.240 port 22: Connexion refused
La connexion est refusée mais je ne sais pas pour quelle raison étant donnée que dans mon fichier de configuration (celui de la VM) de mon serveur SSH n'interdit pas les connexions:
1
2 # This is the ssh client system-wide configuration file. See
3 # ssh_config(5) for more information. This file provides defaults for
4 # users, and the values can be changed in per-user configuration files
5 # or on the command line.
6
7 # Configuration data is parsed as follows:
8 # 1. command line options
9 # 2. user-specific file
10 # 3. system-wide file
11 # Any configuration value is only changed the first time it is set.
12 # Thus, host-specific definitions should be at the beginning of the
13 # configuration file, and defaults at the end.
14
15 # Site-wide defaults for some commonly used options. For a comprehensive
16 # list of available options, their meanings and defaults, please see the
17 # ssh_config(5) man page.
18
19 Host *
20 # ForwardAgent no
21 # ForwardX11 no
22 # ForwardX11Trusted yes
23 # RhostsRSAAuthentication no
24 # RSAAuthentication yes
25 # PasswordAuthentication yes
26 # HostbasedAuthentication no
27 # GSSAPIAuthentication no
28 # GSSAPIDelegateCredentials no
29 # GSSAPIKeyExchange no
30 # GSSAPITrustDNS no
31 # BatchMode no
32 # CheckHostIP yes
33 # AddressFamily any
34 # ConnectTimeout 0
35 # StrictHostKeyChecking ask
36 # IdentityFile ~/.ssh/identity
37 # IdentityFile ~/.ssh/id_rsa
38 # IdentityFile ~/.ssh/id_dsa
39 # IdentityFile ~/.ssh/id_ecdsa
40 # IdentityFile ~/.ssh/id_ed25519
41 # Port 22
42 # Protocol 2
43 # Cipher 3des
44 # Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
45 # MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
46 # EscapeChar ~
47 # Tunnel no
48 # TunnelDevice any:any
49 # PermitLocalCommand no
50 # VisualHostKey no
51 # ProxyCommand ssh -q -W %h:%p gateway.example.com
52 # RekeyLimit 1G 1h
53 SendEnv LANG LC_*
54 HashKnownHosts yes
55 GSSAPIAuthentication yes
56 GSSAPIDelegateCredentials no
Avez-vous une idée ?
Dernière modification par McSource (Le 31/10/2017, à 13:55)
Hors ligne
#2 Le 31/10/2017, à 13:55
- GammaDraconis
Re : connexion SSH refusé
Il est ou ton login ???
Pour te connecter en ssh c'est :
ssh <nom_utilisateur>@<ipaddress>
Discussion sur mon script de post-install pour Ubuntu 20.04LTS : https://forum.ubuntu-fr.org/viewtopic.php?id=2026344
Lien direct script : https://github.com/simbd/Ubuntu_20.04LTS_PostInstall
Démo vidéo (peertube) : https://video.ploud.fr/videos/watch/fb7 … 0d252ed2db
Hors ligne
#3 Le 31/10/2017, à 14:01
- McSource
Re : connexion SSH refusé
Il est ou ton login ???
Pour te connecter en ssh c'est :
ssh <nom_utilisateur>@<ipaddress>
J'utilise root qui est le seul compte présent sur ma VM
ssh root@10.33.2.240
ssh: connect to host 10.33.2.240 port 22: Connection refused
Dernière modification par McSource (Le 31/10/2017, à 14:02)
Hors ligne
#4 Le 31/10/2017, à 14:08
- GammaDraconis
Re : connexion SSH refusé
Tu es sûr que c'est le seul compte présent ? en général sur la plupart des distributions ils demandent de créer au moins 1 compte utilisateur (en dehors de root).
Il est déconseillé de se connecter en root avec ssh par mesure de sécurité, souvent l'accès est bloqué par défaut pour ce compte.
Si tu veux vraiment te connecter avec le compte root, il faut éditer ton fichier /etc/ssh/sshd_config et modifier :
PermitRootLogin no
par :
PermitRootLogin yes
Dans le cas ou la ligne est commenté, tu décommentes et tu met à yes, si la ligne n'est pas présente, tu l'ajoutes.
Dernière modification par GammaDraconis (Le 31/10/2017, à 14:09)
Discussion sur mon script de post-install pour Ubuntu 20.04LTS : https://forum.ubuntu-fr.org/viewtopic.php?id=2026344
Lien direct script : https://github.com/simbd/Ubuntu_20.04LTS_PostInstall
Démo vidéo (peertube) : https://video.ploud.fr/videos/watch/fb7 … 0d252ed2db
Hors ligne
#5 Le 31/10/2017, à 14:08
- michel_04
Re : connexion SSH refusé
Bonjour,
Ton second copié/collé, c'est le /etc/ssh/sshd_config de ta VM ?
A+
Dernière modification par michel_04 (Le 31/10/2017, à 14:09)
:D
De la bonne manière de poser les questions - Trouver de l'aide grâce au Groupe des Parrains Linux - Le Pacte des Gnous
PCs sous Debian Stable & Debian Sid.
Hors ligne
#6 Le 31/10/2017, à 14:25
- McSource
Re : connexion SSH refusé
Oui je n'ai qu’un compte c'est root, et je voudrais me connecter avec celui ci. C'est pour tester mon environnent le seul compte root me suffit
Tu es sûr que c'est le seul compte présent ? en général sur la plupart des distributions ils demandent de créer au moins 1 compte utilisateur (en dehors de root).
Il est déconseillé de se connecter en root avec ssh par mesure de sécurité, souvent l'accès est bloqué par défaut pour ce compte.
Si tu veux vraiment te connecter avec le compte root, il faut éditer ton fichier /etc/ssh/sshd_config et modifier :
PermitRootLogin no
par :
PermitRootLogin yes
Dans le cas ou la ligne est commenté, tu décommentes et tu met à yes, si la ligne n'est pas présente, tu l'ajoutes.
La variable PermitRootLogin n'existe pas dans mon fichier donc je l'ai rajouté puis j'ai mis la valeur a yes. J'ai redémarré le servie mais ça ne change rien
Dernière modification par McSource (Le 31/10/2017, à 14:32)
Hors ligne
#7 Le 31/10/2017, à 14:35
- McSource
Re : connexion SSH refusé
Bonjour,
Ton second copié/collé, c'est le /etc/ssh/sshd_config de ta VM ?
A+
Oui c'est le fichier /etc/ssh/sshd_config de ma VM
Hors ligne
#8 Le 31/10/2017, à 15:00
- GammaDraconis
Re : connexion SSH refusé
Redonne ton fichier sshd_config complet tel qu'il est actuellement.
Attention avec les VM, il faut bien te mettre en réseau par pont (accès par pont) et alors ta VM prendra une ip comme si c'était une machine physique de ton réseau et sera alors accessible par SSH.
Par défaut avec virtualbox tu n'es pas en réseau par pont mais en réseau NAT (translation d'adresse), ça ne marchera pas dans ce cas. Mais je suppose que tu as déja modifié sinon ça te mettrai même pas un accès refusé, ça ne répondrai pas.
Discussion sur mon script de post-install pour Ubuntu 20.04LTS : https://forum.ubuntu-fr.org/viewtopic.php?id=2026344
Lien direct script : https://github.com/simbd/Ubuntu_20.04LTS_PostInstall
Démo vidéo (peertube) : https://video.ploud.fr/videos/watch/fb7 … 0d252ed2db
Hors ligne
#9 Le 31/10/2017, à 15:11
- McSource
Re : connexion SSH refusé
Redonne ton fichier sshd_config complet tel qu'il est actuellement.
Attention avec les VM, il faut bien te mettre en réseau par pont (accès par pont) et alors ta VM prendra une ip comme si c'était une machine physique de ton réseau et sera alors accessible par SSH.
Par défaut avec virtualbox tu n'es pas en réseau par pont mais en réseau NAT (translation d'adresse), ça ne marchera pas dans ce cas. Mais je suppose que tu as déja modifié sinon ça te mettrai même pas un accès refusé, ça ne répondrai pas.
Je suis bien en accès pont et j'arrive à pinger ma VM
sshd_config de ma VM
1
2 # This is the ssh client system-wide configuration file. See
3 # ssh_config(5) for more information. This file provides defaults for
4 # users, and the values can be changed in per-user configuration files
5 # or on the command line.
6
7 # Configuration data is parsed as follows:
8 # 1. command line options
9 # 2. user-specific file
10 # 3. system-wide file
11 # Any configuration value is only changed the first time it is set.
12 # Thus, host-specific definitions should be at the beginning of the
13 # configuration file, and defaults at the end.
14
15 # Site-wide defaults for some commonly used options. For a comprehensive
16 # list of available options, their meanings and defaults, please see the
17 # ssh_config(5) man page.
18
19 Host *
20 # ForwardAgent no
21 # ForwardX11 no
22 # ForwardX11Trusted yes
23 # RhostsRSAAuthentication no
24 # RSAAuthentication yes
25 # PasswordAuthentication yes
26 # HostbasedAuthentication no
27 # GSSAPIAuthentication no
28 # GSSAPIDelegateCredentials no
29 # GSSAPIKeyExchange no
30 # GSSAPITrustDNS no
31 # BatchMode no
32 # CheckHostIP yes
33 # AddressFamily any
34 # ConnectTimeout 0
35 # StrictHostKeyChecking ask
36 # IdentityFile ~/.ssh/identity
37 # IdentityFile ~/.ssh/id_rsa
38 # IdentityFile ~/.ssh/id_dsa
39 # IdentityFile ~/.ssh/id_ecdsa
40 # IdentityFile ~/.ssh/id_ed25519
41 # Port 22
42 # Protocol 2
43 # Cipher 3des
44 # Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
45 # MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
46 # EscapeChar ~
47 # Tunnel no
48 # TunnelDevice any:any
49 # PermitLocalCommand no
50 # VisualHostKey no
51 # ProxyCommand ssh -q -W %h:%p gateway.example.com
52 # RekeyLimit 1G 1h
53 SendEnv LANG LC_*
54 HashKnownHosts yes
55 GSSAPIAuthentication yes
56 GSSAPIDelegateCredentials no
57 PermitRootLogin yes
Dernière modification par McSource (Le 31/10/2017, à 15:12)
Hors ligne
#10 Le 31/10/2017, à 17:13
- GammaDraconis
Re : connexion SSH refusé
Ta config est mauvaise, je sais pas ce que tu as fabriqué, il y a pleins de truc qui te manque.
Il faut que tu décommentes certaines lignes, n'oublie que quand il y a un # devant ce n'est pas pris en compte :
Commence d'abord par décommenter ceci :
# Port 22
en remplaçant par :
Port 22
ça c'est sur que ça doit être décommenté.
test déjà comme ça et si ça ne marche toujours pas, test en décommentant aussi :
Protocol 2
UsePrivilegeSeparation yes
PasswordAuthentication yes
tu utilises bien d'authentification par mdp et non par clé ?
Car si tu as généré une clé, c'est facile de te tromper.
et j'en ai peut être oublié au niveau des lignes à décommenter. Au pire repart sur une config par défaut.
Dernière modification par GammaDraconis (Le 31/10/2017, à 17:14)
Discussion sur mon script de post-install pour Ubuntu 20.04LTS : https://forum.ubuntu-fr.org/viewtopic.php?id=2026344
Lien direct script : https://github.com/simbd/Ubuntu_20.04LTS_PostInstall
Démo vidéo (peertube) : https://video.ploud.fr/videos/watch/fb7 … 0d252ed2db
Hors ligne
#11 Le 31/10/2017, à 19:17
- maxire
Re : connexion SSH refusé
Salut,
Non cette configuration n'est pas particulièrement mauvaise, en fait ce n'est même pas celle du serveur c'est celle du client comme indiqué dans les commentaires;
1
2 # This is the ssh client system-wide configuration file. See
3 # ssh_config(5) for more information. This file provides defaults for
4 # users, and the values can be changed in per-user configuration files
5 # or on the command line.
6
7 # Configuration data is parsed as follows:
8 # 1. command line options
9 # 2. user-specific file
10 # 3. system-wide file
11 # Any configuration value is only changed the first time it is set.
12 # Thus, host-specific definitions should be at the beginning of the
13 # configuration file, and defaults at the end
McSource, si tu essaies de paramétrer ton serveur en utilisant le fichier de configuration du client c'est mal parti!
GammaDraconnis, les lignes commentées indiquent simplement les valeurs par défaut des options de configuration, c'est d'ailleurs bien le port 22 qui est utilisé lors des tentatives de connexions comme indiqué par les message d'erreurs.
Une configuration de serveur cela ressemble à ceci:
# $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 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#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
# 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
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#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 no to disable s/key passwords
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
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no # pam does that
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# override default of no subsystems
Subsystem sftp /usr/lib/ssh/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 maxire (Le 31/10/2017, à 19:21)
Maxire
Archlinux/Mate + Ubuntu 22.04 + Archlinux/Gnome sur poste de travail
Hors ligne
#12 Le 31/10/2017, à 19:25
- GammaDraconis
Re : connexion SSH refusé
Ah mais d'accord ! moi je pensais qu'il avait donné la config ssh de son serveur ! C'est pour ça que je trouvais sa config bizarre.
Alors effectivement McSource, tu t'es trompé en donnant ta config, tu as donné celle de ton client SSH et non de ton serveur !
Dernière modification par GammaDraconis (Le 31/10/2017, à 19:26)
Discussion sur mon script de post-install pour Ubuntu 20.04LTS : https://forum.ubuntu-fr.org/viewtopic.php?id=2026344
Lien direct script : https://github.com/simbd/Ubuntu_20.04LTS_PostInstall
Démo vidéo (peertube) : https://video.ploud.fr/videos/watch/fb7 … 0d252ed2db
Hors ligne
Pages : 1