织物曾经与ssh-keys一起工作,但现在不再了

我有我的SSH密钥正确设置,我可以SSH密码进入远程机器。

然而,我的结构部署脚本,可以自动validation,直到几个小时前,每当我试图部署到远程机器开始问我的私钥密码。

即使我input密码,似乎也不在乎我是否给出了正确的密码,并提示系统login,就好像我根本没有ssh密钥。

请记住,我是一名开发人员,而不是系统工程师,他们不熟悉Fabric的工作原理。 我错过了一些明显的可能性相当高。 任何解决scheme,甚至指针的地方,将不胜感激。

这是我从真实部署脚本中获得的校对脚本:

#!/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() 

这里是来自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 

编辑:

我的~/.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 

我想澄清,在我的本地机器上,我确实可以成功连接到远程机器,如下所示:

 # ssh remote-machine 

我发现这个问题。

如果我重新启动计算机,我必须重新添加所有密钥,即ssh-add <path/to/key.pem>

该线程解释了所需的configuration,因此您不必在每次重新启动计算机时重新添encryption钥。