configura o SSH no Linux para efetuar login sem senha

1

Eu configurei o ssh para fazer login no meu servidor remoto sem senha, usando as etapas fornecidas no tutorial neste URL:   Login SSH sem senha .

Quando tento fazer login no servidor usando apenas o comando ssh:

$ ssh [email protected]

funciona bem, e consigo fazer o login sem digitar a senha, mas quando tento copiar arquivos do servidor local para o remoto usando o comando scp:

$ scp /location/to/file/localserver user@server:location/whereto/copy

ele me pede para digitar uma senha que é estranha!

Também verifiquei se todas as pastas têm as permissões corretas, conforme explicado no URL acima.

Alguém sabe como corrigir esse problema?

Executing: program /usr/bin/ssh host *.*.*.*, user ssadmin, command scp -v -t /home/ssadmin/nexthink_log'

OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013'
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to *.*.*.* [*.*.*.*] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4* compat 0x00000000
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: kex: diffie-hellman-group-exchange-sha1 need=16 dh_need=16
debug1: kex: diffie-hellman-group-exchange-sha1 need=16 dh_need=16
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA **:**:**:**:**:**:**:**:**:**:**:**:**:**
debug1: Host '*.*.*.*' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: Next authentication method: password

ssadmin@*.*.*.*'s password:
    
por SRoss 05.04.2017 / 13:16

3 respostas

2

Primeiro, entre no seu PC linux e gere um par de chaves públicas usando o seguinte comando.

$ ssh-keygen -t rsa

Quando pedir uma senha, basta pressionar enter.

crie uma pasta .ssh no usuário do servidor e nela, carregue a nova chave pública gerada (id_rsa.pub) no seu PC, sob o diretório .ssh do usuário, como um nome de arquivo authorized_keys.

Defina as permissões:

$ ssh [email protected] "chmod 700 .ssh; chmod 640 .ssh/authorized_keys" 

E é isso!

Login seguro sem senha.

    
por 05.04.2017 / 15:03
2

Você pode usar o comando ssh-copy-id

$ ssh-copy-id user@hostname

Isso simplesmente adicionará as chaves locais ao arquivo authorized_keys no servidor remoto. Certifique-se de poder usar as chaves autorizadas ativando-as no arquivo sshd_config . Dessa forma, você nunca receberá uma solicitação de senha nem em ssh ou em scp .

    
por 05.04.2017 / 18:06
0

Quando você coloca a senha, a cópia segura funciona?

Se você obtiver permissões negadas, poderá ser apenas o local para o qual você está tentando copiar, não permitindo gravações pelo usuário remoto.

    
por 15.01.2018 / 20:16

Tags