Eu criei um usuário sem uma senha
$getent passwd logcoll
logcoll:x:998:999:Log Collector,,,:/var/backups/logcoll:/bin/sh
Este usuário não possui senha e esta máquina requer que os usuários efetuem login com chaves SSH.
Eu copiei minha identidade para /var/backups/logcoll/.ssh/authorized_keys
. Mas quando tento fazer o login nesta máquina, recebo um erro:
ssh -i .ssh/id_rsa logcoll@server
Permission denied (publickey)
Mas, se criar uma senha para esse usuário com passwd logcoll
, posso fazer o login usando o comando:
ssh -i .ssh/id_rsa logcoll@data3
.
Portanto, a pergunta é: como habilitar a autenticação baseada em chave sem definir uma senha baseada em pam para os usuários?
atualizado
user@localhost:~$ ssh -v -i .ssh/id_rsa logcoll@server
OpenSSH_6.0p1 Debian-4+deb7u2, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /home/user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to user [1x.x.x.21] port 22.
debug1: Connection established.
debug1: identity file .ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file .ssh/id_rsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-4+deb7u2
debug1: match: OpenSSH_6.0p1 Debian-4+deb7u2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 15:13:8b:62:49:ad:5a:01:e6:5f:13:bd:10:c3:c1:28
debug1: Host 'data3' is known and matches the ECDSA host key.
debug1: Found key in /home/user/.ssh/known_hosts:16
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: .ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
user@localhost:~$
As permissões do arquivo:
root@server:/var/backups/logcoll#ls -ld .ssh
drwx------ 2 logcoll logcoll 4096 Dec 1 15:36 .ssh
root@data3:/var/backups/logcoll#ls -ld .ssh/authorized_keys
-rw------- 1 logcoll logcoll 391 Dec 1 15:29 .ssh/authorized_keys