Não consigo configurar o login sem senha em um servidor Ubuntu. Mesmo se eu especificar uma chave, uma senha será solicitada.
A mesma chave pode me conectar corretamente em outro servidor. Portanto, não acho que seja um problema de permissão do cliente.
Saída do servidor:
root@server:~# /usr/sbin/sshd -d -p 2222
debug1: sshd version OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type RSA
debug1: private host key: #0 type 1 RSA
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type DSA
debug1: private host key: #1 type 2 DSA
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type ECDSA
debug1: private host key: #2 type 3 ECDSA
debug1: private host key: #3 type 4 ED25519
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-d'
debug1: rexec_argv[2]='-p'
debug1: rexec_argv[3]='2222'
Set /proc/self/oom_score_adj from 0 to -1000
debug1: Bind to port 2222 on 0.0.0.0.
Server listening on 0.0.0.0 port 2222.
debug1: Bind to port 2222 on ::.
Server listening on :: port 2222.
debug1: Server will not fork when running in debugging mode.
debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8
debug1: inetd sockets after dupping: 3, 3
Connection from CLIENTIP port 48264 on SERVERIP port 2222
debug1: Client protocol version 2.0; client software version OpenSSH_9.3p1 Ubuntu-1ubuntu3.2
debug1: match: OpenSSH_9.3p1 Ubuntu-1ubuntu3.2 pat OpenSSH* compat 0x04000000
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.13
debug1: permanently_set_uid: 104/65534 [preauth]
debug1: list_hostkey_types: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
debug1: SSH2_MSG_KEXINIT sent [preauth]
debug1: SSH2_MSG_KEXINIT received [preauth]
debug1: kex: client->server [email protected] <implicit> none [preauth]
debug1: kex: server->client [email protected] <implicit> none [preauth]
debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
debug1: SSH2_MSG_NEWKEYS sent [preauth]
debug1: expecting SSH2_MSG_NEWKEYS [preauth]
debug1: SSH2_MSG_NEWKEYS received [preauth]
debug1: KEX done [preauth]
debug1: userauth-request for user ubuntu service ssh-connection method none [preauth]
debug1: attempt 0 failures 0 [preauth]
debug1: PAM: initializing for "ubuntu"
debug1: PAM: setting PAM_RHOST to "CLIENT HOSTNAME"
debug1: PAM: setting PAM_TTY to "ssh"
Saída do cliente:
simone@client:~/.ssh$ ssh -vvv mmo
OpenSSH_9.3p1 Ubuntu-1ubuntu3.2, OpenSSL 3.0.10 1 Aug 2023
debug1: Reading configuration data /home/simone/.ssh/config
debug1: /home/simone/.ssh/config line 1: Applying options for mmo
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname SERVERIP is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/simone/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/simone/.ssh/known_hosts2'
debug3: ssh_connect_direct: entering
debug1: Connecting to SERVERIP port 2222.
debug3: set_sock_tos: set socket 3 IP_TOS 0x10
debug1: Connection established.
debug1: identity file /home/simone/.ssh/id_rsa type 0
debug1: identity file /home/simone/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.3p1 Ubuntu-1ubuntu3.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.13
debug1: compat_banner: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.13 pat OpenSSH_6.6.1* compat 0x04000002
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to SERVERIP:2222 as 'ubuntu'
debug3: put_host_port: SERVERIP:2222
debug1: load_hostkeys: fopen /home/simone/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug3: order_hostkeyalgs: no algorithms matched; accept original
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: [email protected],curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c,[email protected]
debug2: host key algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],rsa-sha2-512,rsa-sha2-256
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:NeYvqJmThTo4GAxqqkz3qMbaN4KIJbUUPiGapVhoHgI
debug3: put_host_port: SERVERIP:2222
debug3: put_host_port: SERVERIP:2222
debug1: load_hostkeys: fopen /home/simone/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: checking without port identifier
debug3: record_hostkey: found key type ED25519 in file /home/simone/.ssh/known_hosts:1
debug3: load_hostkeys_file: loaded 1 keys from SERVERIP
debug1: load_hostkeys: fopen /home/simone/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host 'SERVERIP' is known and matches the ED25519 host key.
debug1: Found key in /home/simone/.ssh/known_hosts:1
debug1: found matching key w/out port
debug1: check_host_key: hostkey not known or explicitly trusted: disabling UpdateHostkeys
debug3: send packet: type 21
debug2: ssh_set_newkeys: mode 1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: ssh_set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug3: ssh_get_authentication_socket_path: path '/run/user/1000/keyring/ssh'
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: agent returned 2 keys
debug1: Will attempt key: /home/simone/.ssh/id_rsa RSA SHA256:lHWoOcJ9LHEs3BLMMf/gBpeD9jyy6+OiC5PatiocLQc explicit agent
debug1: Will attempt key: simone@client RSA SHA256:Wg678UTK8aU1CFEw028Xomk9oPArJQ9nZItw2dIQoDA agent
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/simone/.ssh/id_rsa RSA SHA256:lHWoOcJ9LHEs3BLMMf/gBpeD9jyy6+OiC5PatiocLQc explicit agent
debug1: send_pubkey_test: no mutual signature algorithm
debug1: Offering public key: simone@client RSA SHA256:Wg678UTK8aU1CFEw028Xomk9oPArJQ9nZItw2dIQoDA agent
debug1: send_pubkey_test: no mutual signature algorithm
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
ubuntu@SERVERIP's password:
Meu ~/.ssh/config
arquivo:
Host mmo
HostName SERVERIP
User ubuntu
Port 2222
IdentityFile ~/.ssh/id_rsa
Consigo fazer login corretamente com nome de usuário e senha. Eu tentei chaves diferentes, incluindo uma chave que com certeza estava funcionando há alguns meses.
Estas são as permissões no servidor:
root@vultr:/home/ubuntu/.ssh# ls -la
total 72
drwx------ 3 ubuntu ubuntu 4096 Feb 18 13:26 .
drwxr-xr-x 26 ubuntu ubuntu 36864 Feb 18 13:23 ..
-rw-r--r-- 1 ubuntu ubuntu 2563 Feb 18 13:26 authorized_keys
-rw------- 1 ubuntu ubuntu 141 Dec 4 2015 config
-rw------- 1 ubuntu ubuntu 1675 Jul 30 2022 id_rsa
-rw-r--r-- 1 ubuntu ubuntu 394 Jul 30 2022 id_rsa.pub
drwxrwxr-x 2 ubuntu ubuntu 4096 Jul 30 2022 key-backup
-rw-r--r-- 1 ubuntu ubuntu 6856 Jul 30 2022 known_hosts
Meu sshd_config
arquivo tem estas linhas:
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile /home/ubuntu/.ssh/authorized_keys
Alguma ideia?
Seu novo cliente (9.3) desativa
ssh-rsa
chaves RSA — porque esse método agora é considerado inseguro; ele permite apenas osrsa-sha2-*
métodos mais novos e melhores - MAS seu servidor antigo (OpenSSH 6.6) SÓ suportassh-rsa
e nunca ouviu falar dersa-sha2
. Isto é o que a mensagem de logno mutual signature algorithm
significa.Especifique
-oPubkeyAcceptedAlgorithms=ssh-rsa
-- ou=+ssh-rsa
para continuar permitindo outros tipos de chave, mas parece que você não tem outros. Como alternativa, configure isso (sem-o
) em~/.ssh/config
ou/etc/ssh/ssh_config
. (Abaixo de 8.5 você precisava do nome mais antigoPubkeyAcceptedKeyTypes
.)Os itens a seguir são, na verdade, idiotas (que marquei), mas por algum motivo, pesquisando no Google (como eu esperaria que você fizesse) só me encontra o primeiro:
Seu cliente não pode aceitar a chave RSA do host pelo mesmo motivo, ou sua
ssh-dss
chave (DSA), que agora é insegura, mas o host também oferece chaves ECDSA e Ed25519 que ainda são seguras, e a chave Ed25519 é selecionada e usada porquessh-ed25519
foi listado anteriormente na proposta do cliente. Existem algumas perguntas sobre pessoas que não conseguem se conectar com clientes SSH recentes a servidores antigos ou de baixa qualidade com apenasssh-rsa
e/oussh-dss
chaves, que precisam de uma correção semelhante.