Q: paramiko/SSH/ how to get a remote host_key
Charles_hans
charles_hans at yahoo.com
Wed Jan 30 13:54:47 EST 2008
I tried to get what host_key has been aquired after AutoPolicy is set. I
added the following code just before client.close() in rosty's final code:
try:
host_keys =
paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))
except IOError:
try:
host_keys =
paramiko.util.load_host_keys(os.path.expanduser('~/ssh/known_hosts'))
except IOError:
print '*** Unable to open host keys file'
I still got 'Unable to open host keys file'. Can you tell me how to get the
remote host_key under this situation? Thanks!
Charles
1/30/2008
by Guilherme Polo Jan 21, 2008; 09:08am :
2008/1/21, DHR <dima.hristov at gmail.com>:
Very nice =)
Just an advice, you dont need to import base64. Method decode of
strings allows you to specify encoding as 'base64' to perform needed
operations.
by rosty Jan 21, 2008; 08:43am :
Thank you! Now it works and the code looks like this:
import paramiko
import base64
from paramiko import AutoAddPolicy, SSHClient
client = paramiko.SSHClient()
client.set_missing_host_key_policy(AutoAddPolicy())
client.connect('hostIP', username='uname', password='pass')
stdin, stdout, stderr = client.exec_command('ls')
for line in stdout:
print '... ' + line.strip('\n')
client.close()
--
View this message in context: http://www.nabble.com/Q%3A-paramiko-SSH--how-to-get-a-remote-host_key-tp14996119p15189222.html
Sent from the Python - python-list mailing list archive at Nabble.com.
More information about the Python-list
mailing list