>>>dns_node = [i for i in conn.list_nodes() if i.uuid == 'xxxxxxxxxxxxxxxxxxxxxxx07xxxxxxxxxx']
>>>try_script = 'path/to/somefile.py'
>>>dns_file = FileDeployment(try_script, target='/home/ec2-user')
>>>ssh_client = SSHClient(dns_node[0].public_ip[0], username='ec2-user', key=os.path.expanduser("~/.ssh/id_rsa"))
>>>dns_file.run(dns_node, ssh_client)我已经验证了这些赋值的每个变量都显示了我所理解的适当类型。当我尝试这样做时,我得到了以下结果:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/ec2-user/Envs/libcloud/lib/python2.7/site-packages/libcloud/compute/deployment.py", line 111, in run contents=content) File "/Users/ec2-user/Envs/libcloud/lib/python2.7/site-packages/libcloud/compute/ssh.py", line 174, in put sftp = self.client.open_sftp() File "/Users/ec2-user/Envs/libcloud/lib/python2.7/site-packages/paramiko/client.py", line 414, in open_sftp return self._transport.open_sftp_client() AttributeError: 'NoneType' object has no attribute 'open_sftp_client'
这是我为上面的对象准备的:
dns_node:
`[<Node: uuid=xxxxxxxxxxxxxxxxxxxxxxx, name=ec2_node1, state=0, public_ips=['xx.xxx.xxx.xx'], provider=Amazon EC2 ...>]`dns_file:
<libcloud.compute.deployment.FileDeployment object at 0x10d58de50>
ssh_client:
`<libcloud.compute.ssh.ParamikoSSHClient object at 0x10d55e950>`ssh_client.connect:
<bound method ParamikoSSHClient.connect of <libcloud.compute.ssh.ParamikoSSHClient object at 0x10d55e950>>
我遗漏了什么?
发布于 2013-07-16 01:11:49
转到paramiko级别,发现我引用的私钥文件是加密的,这在正在建立的ssh连接中没有处理。因此,即使有一个SSHCLient对象,它也无法连接。
pkey = paramiko.RSAKey.from_private_key_file(os.path.expanduser('~/.ssh/id_rsa'))回溯(最近一次调用):文件"",第1行,文件"/Users/ec2-user/Envs/libcloud/lib/python2.7/site-packages/paramiko/pkey.py",第198行,from_private_key_file密钥= cls(filename=filename,password=password)文件pkey51行,在init self._from_private_key_file(文件名,密码)文件数据行163,在_from_private_key_file data = self._read_private_key_file('RSA',文件名,密码)文件"/Users/ec2-user/Envs/libcloud/lib/python2.7/site-packages/paramiko/pkey.py",行280,在"/Users/ec2-user/Envs/libcloud/lib/python2.7/site-packages/paramiko/pkey.py",data =self._read_private_key( _read_private_key_file,f,password)文件第323行中,在_read_private_key提升PasswordRequiredException(‘私钥文件已加密’)中,paramiko.PasswordRequiredException:私钥文件已加密
我指定了一个无密码的密钥,连接就通过了。
https://stackoverflow.com/questions/17646241
复制相似问题