1
>>>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)

I've verified that each of these variables assigned show me what I understand to be of the appropriate type. When I try this, I get the following:

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'

This is what I have for the above objects:

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>>

What am I missing?

4

1 回答 1

0

转到 paramiko 级别,发现我引用的私钥文件是加密的,在建立的 ssh 连接中没有处理。因此,即使有一个 SSHCLient 对象,它也无法连接。

pkey = paramiko.RSAKey.from_private_key_file(os.path.expanduser('~/.ssh/id_rsa')) Traceback(最近一次调用最后):文件“”,第1行,在文件“/Users/ec2-user/Envs /libcloud/lib/python2.7/site-packages/paramiko/pkey.py”,第 198 行,在 from_private_key_file key = cls(filename=filename, password=password) 文件“/Users/ec2-user/Envs/libcloud/ lib/python2.7/site-packages/paramiko/rsakey.py”,第 51 行,在init self._from_private_key_file(文件名,密码)文件“/Users/ec2-user/Envs/libcloud/lib/python2.7/site-packages/paramiko/rsakey.py”,第163行,在_from_private_key_file数据= self._read_private_key_file(' RSA',文件名,密码)文件“/Users/ec2-user/Envs/libcloud/lib/python2.7/site-packages/paramiko/pkey.py”,第 280 行,在 _read_private_key_file 数据 = self._read_private_key(tag, f,密码)文件“/Users/ec2-user/Envs/libcloud/lib/python2.7/site-packages/paramiko/pkey.py”,第323行,在_read_private_key raise PasswordRequiredException('Private key file is encrypted') paramiko.PasswordRequiredException:私钥文件已加密

我指定了一个无密码密钥,并且连接通过了。

于 2013-07-15T17:11:48.737 回答