首先,我試圖讓織物工作,但它一直要求我輸入密碼。paramiko,不是跟ssh-agent說話。在織物中的相同行爲
所以我試圖減少這個問題。也許從Python創建一個SSH連接將是一個很好的POC。我發現fabric使用parmiko進行SSH處理。嗯。好的,讓我們試着讓一個例子工作。
這是我寫的。
from ssh import *
import os
print "SSH-AGENT VARS"
print "SSH_AGENT_PID: %s " % os.environ['SSH_AGENT_PID']
print "SSH_AUTH_SOCK: %s " % os.environ['SSH_AUTH_SOCK']
a = Agent()
keys=a.get_keys()
print keys.count("192.168.1.10")
client = SSHClient()
client.load_system_host_keys()
client.connect('192.168.1.10')
以下錯誤信息所導致的:
% ./ssh_test.py
SSH-AGENT VARS
SSH_AGENT_PID: 26557
SSH_AUTH_SOCK: /tmp/ssh-pZHBElj26556/agent.26556
0
Traceback (most recent call last):
File "./ssh_test.py", line 18, in <module>
client.connect('192.168.1.10')
File "/usr/local/lib/python2.7/dist-packages/ssh/client.py", line 332, in connect
self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys)
File "/usr/local/lib/python2.7/dist-packages/ssh/client.py", line 493, in _auth
raise saved_exception
ssh.PasswordRequiredException: Private key file is encrypted
的ssh-agent在我的會話中運行的,我可以ssh到那個盒子,沒有問題,它並沒有提示我輸入密碼或任何東西。
我猜paramiko無法連接到正在運行的ssh-agent的一些奇怪的原因。
有沒有其他人有過這樣的問題?我正在使用Ubuntu 11.10
我似乎記得嘗試使用Fabric並且遇到類似的問題,可能它已被打破了一段時間?
我連接,只使用主機名作爲參數。這是根據文件。
http://www.lag.net/paramiko/docs/paramiko.SSHClient-class.html
connect(self, hostname, port=22, username=None, password=None, pkey=None, key_filename=None, timeout=None, allow_agent=True, look_for_keys=True, compress=False)
我使用的面料在Ubuntu 11.10也沒有任何問題。這聽起來像是光纖網不能訪問與您的控制檯ssh相同的密鑰文件,或者您使用了錯誤的登錄名。你記得在你的fabfile中設置'env.user ='my_user''嗎? – 2012-03-26 14:44:09
試過了,同樣的問題。我猜猜問題在於paramiko而不是織物。讓paramiko先工作將是一個好的一步。這就是爲什麼我創建了上面的小測試腳本。 – 2012-03-26 15:43:44
您是否嘗試過創建分支新的RSA密鑰,確保它沒有密碼,在服務器上安裝並使用它? – 2012-03-26 15:46:38