Fabric usado para trabalhar com chaves ssh, mas não mais

3

Eu tenho minha chave ssh configurada corretamente e posso ssh na máquina remota sem senha.

No entanto, meu script de implantação de malha, que pode ser autenticado automaticamente até algumas horas atrás, começou a me pedir minha senha de chave privada sempre que eu tentava implantar na máquina remota.

Mesmo que eu digite minha frase-senha, não parece se importar se eu der as corretas e solicitará o login do sistema, como se eu não tivesse chaves ssh.

Por favor, tenha em mente que eu sou um desenvolvedor e não um engenheiro de sistemas, que não está familiarizado com o funcionamento do Fabric. A possibilidade de ter perdido algo óbvio é bem alta. Qualquer solução ou mesmo um ponteiro de onde olhar será muito apreciado.

Este é um script de prova derivado do script de implantação real:

#!/usr/bin/env python2

import sys
from fabric.api import *
from fabric.network import ssh

ssh.util.log_to_file("paramiko.log", 10)

@hosts(['host-ip-address'])

def boot():
    env.use_ssh_config = True
    env.user = 'userlogin'
    env.key_filename = ['~/.ssh/some-public-key.pem']
    env.gateway = '[email protected]'
    execute(a)

def a():
    run('ls')

boot()

E aqui está a mensagem de log do paramiko:

DEB [20141007-19:22:50.804] thr=1   paramiko.transport: starting thread (client mode): 0xfe2790L
INF [20141007-19:22:50.847] thr=1   paramiko.transport: Connected (version 2.0, client OpenSSH_6.2)
DEB [20141007-19:22:50.856] thr=1   paramiko.transport: kex algos:[u'ecdh-sha2-nistp256', u'ecdh-sha2-nistp384', u'ecdh-sha2-nistp521', u'diffie-hellman-group-exchange-sha256', u'diffie-hellman-group-exchange-sha1', u'diffie-hellman-group14-sha1', u'diffie-hellman-group1-sha1'] server key:[u'ssh-rsa', u'ssh-dss', u'ecdsa-sha2-nistp256'] client encrypt:[u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'arcfour256', u'arcfour128', u'[email protected]', u'[email protected]', u'aes128-cbc', u'3des-cbc', u'blowfish-cbc', u'cast128-cbc', u'aes192-cbc', u'aes256-cbc', u'arcfour', u'[email protected]'] server encrypt:[u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'arcfour256', u'arcfour128', u'[email protected]', u'[email protected]', u'aes128-cbc', u'3des-cbc', u'blowfish-cbc', u'cast128-cbc', u'aes192-cbc', u'aes256-cbc', u'arcfour', u'[email protected]'] client mac:[u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'hmac-md5', u'hmac-sha1', u'[email protected]', u'[email protected]', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-ripemd160', u'[email protected]', u'hmac-sha1-96', u'hmac-md5-96'] server mac:[u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'hmac-md5', u'hmac-sha1', u'[email protected]', u'[email protected]', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-ripemd160', u'[email protected]', u'hmac-sha1-96', u'hmac-md5-96'] client compress:[u'none', u'[email protected]'] server compress:[u'none', u'[email protected]'] client lang:[u''] server lang:[u''] kex follows?False
DEB [20141007-19:22:50.856] thr=1   paramiko.transport: Ciphers agreed: local=aes128-ctr, remote=aes128-ctr
DEB [20141007-19:22:50.856] thr=1   paramiko.transport: using kex diffie-hellman-group14-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none
DEB [20141007-19:22:50.903] thr=1   paramiko.transport: Switch to new keys ...
DEB [20141007-19:22:50.907] thr=2   paramiko.transport: Trying key 3433922e6c7bef8672043fbfe07c22f3 from /Users/ganeshwara/.dme/sg-master.pem
DEB [20141007-19:22:50.954] thr=1   paramiko.transport: userauth is OK
INF [20141007-19:22:51.033] thr=1   paramiko.transport: Authentication (publickey) failed.
DEB [20141007-19:22:51.040] thr=2   paramiko.transport: Trying SSH agent key f8f4822cc3d40df79b9f7c79f219c42c
DEB [20141007-19:22:51.045] thr=1   paramiko.transport: userauth is OK
INF [20141007-19:22:51.061] thr=1   paramiko.transport: Authentication (publickey) failed.
DEB [20141007-19:22:51.704] thr=3   paramiko.transport: starting thread (client mode): 0xff0a10L
INF [20141007-19:22:51.723] thr=3   paramiko.transport: Connected (version 2.0, client OpenSSH_6.2)
DEB [20141007-19:22:51.728] thr=3   paramiko.transport: kex algos:[u'ecdh-sha2-nistp256', u'ecdh-sha2-nistp384', u'ecdh-sha2-nistp521', u'diffie-hellman-group-exchange-sha256', u'diffie-hellman-group-exchange-sha1', u'diffie-hellman-group14-sha1', u'diffie-hellman-group1-sha1'] server key:[u'ssh-rsa', u'ssh-dss', u'ecdsa-sha2-nistp256'] client encrypt:[u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'arcfour256', u'arcfour128', u'[email protected]', u'[email protected]', u'aes128-cbc', u'3des-cbc', u'blowfish-cbc', u'cast128-cbc', u'aes192-cbc', u'aes256-cbc', u'arcfour', u'[email protected]'] server encrypt:[u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'arcfour256', u'arcfour128', u'[email protected]', u'[email protected]', u'aes128-cbc', u'3des-cbc', u'blowfish-cbc', u'cast128-cbc', u'aes192-cbc', u'aes256-cbc', u'arcfour', u'[email protected]'] client mac:[u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'hmac-md5', u'hmac-sha1', u'[email protected]', u'[email protected]', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-ripemd160', u'[email protected]', u'hmac-sha1-96', u'hmac-md5-96'] server mac:[u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'[email protected]', u'hmac-md5', u'hmac-sha1', u'[email protected]', u'[email protected]', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-ripemd160', u'[email protected]', u'hmac-sha1-96', u'hmac-md5-96'] client compress:[u'none', u'[email protected]'] server compress:[u'none', u'[email protected]'] client lang:[u''] server lang:[u''] kex follows?False
DEB [20141007-19:22:51.728] thr=3   paramiko.transport: Ciphers agreed: local=aes128-ctr, remote=aes128-ctr
DEB [20141007-19:22:51.728] thr=3   paramiko.transport: using kex diffie-hellman-group14-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none
DEB [20141007-19:22:51.799] thr=3   paramiko.transport: Switch to new keys ...
DEB [20141007-19:22:51.806] thr=2   paramiko.transport: Trying key 3433922e6c7bef8672043fbfe07c22f3 from /Users/ganeshwara/.dme/sg-master.pem
DEB [20141007-19:22:51.848] thr=3   paramiko.transport: userauth is OK
INF [20141007-19:22:51.932] thr=3   paramiko.transport: Authentication (publickey) failed.
DEB [20141007-19:22:51.938] thr=2   paramiko.transport: Trying SSH agent key f8f4822cc3d40df79b9f7c79f219c42c
DEB [20141007-19:22:51.943] thr=3   paramiko.transport: userauth is OK
INF [20141007-19:22:51.955] thr=3   paramiko.transport: Authentication (publickey) failed.
DEB [20141007-19:22:51.979] thr=3   paramiko.transport: userauth is OK
DEB [20141007-19:22:51.984] thr=3   paramiko.transport: Authentication type (password) not permitted.
DEB [20141007-19:22:51.985] thr=3   paramiko.transport: Allowed methods: [u'publickey']
DEB [20141007-19:22:52.717] thr=1   paramiko.transport: EOF in transport thread
DEB [20141007-19:22:52.794] thr=3   paramiko.transport: EOF in transport thread

EDITAR:

Meu ~/.ssh/config

Host gateway
 HostName gateway.com
 User user
 Port 22
 IdentityFile ~/.ssh/some-public-key.pem

Host remote-machine
 HostName host-ip-address
 User userlogin
 IdentityFile ~/.ssh/remote-machine.pem
 ProxyCommand ssh gateway -W %h:%p

Eu gostaria de esclarecer que na minha máquina local, eu posso realmente conectar a máquina remota com sucesso, assim:

# ssh remote-machine
    
por lolski 08.10.2014 / 04:30

1 resposta

2

Eu encontrei o problema.

Eu tenho que adicionar novamente todas as chaves, ou seja, ssh-add <path/to/key.pem> se eu reiniciar o computador.

Este tópico explica a configuração necessária para que você não tenha que adicionar novamente as chaves toda vez que a máquina for reinicializada.

    
por 08.10.2014 / 08:37