Re: Q: paramiko/SSH/ how to get a remote host_key



2008/1/21, DHR <dima.hristov@xxxxxxxxx>:
I'm trying to run the simpliest example form paramiko readme(Homepage:
http://www.lag.net/paramiko/), and
cannot find out how to get the remote SSH server host_key.


This is the code. It is supposed to connect to a remote SSH host and
execute an 'ls' command:

import paramiko, base64

key = paramiko.RSAKey(data=base64.decodestring('AAA...'))
client = paramiko.SSHClient()
client.get_host_keys().add('ssh.example.com', 'ssh-rsa', key)
client.connect('227.112.168.273', username='uname', password='pass')
stdin, stdout, stderr = client.exec_command('ls')
for line in stdout:
print '... ' + line.strip('\n')

client.close()

Now, if I understand it correctly I need to get somehow the host_key
from the server and
write it insted of the 'AAA...' thing. Is there a command to get the
host_key from a remote SSH
server?
--
http://mail.python.org/mailman/listinfo/python-list


You need a key to connect to that server, so you should want this:

keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))

Then keys[hostname] should contain a RSAKey object that you are looking for


--
-- Guilherme H. Polo Goncalves
.



Relevant Pages

  • Q: paramiko/SSH/ how to get a remote host_key
    ... I'm trying to run the simpliest example form paramiko readme(Homepage: ... cannot find out how to get the remote SSH server host_key. ... for line in stdout: ...
    (comp.lang.python)
  • increasing failed sshd logins/clearing breadcrumb trails
    ... I've noticed a few posts over the past week or so regarding users' ... servers being probed by remote ssh attempts. ... spoofing from) one IP hammered my server with login ... failed root password at 20:22:13 Eastern Time. ...
    (freebsd-questions)
  • Re: increasing failed sshd logins/clearing breadcrumb trails
    ... John DeStefano said the following on 9/14/2004 10:15 PM: ... >servers being probed by remote ssh attempts. ... >spoofing from) one IP hammered my server with login ...
    (freebsd-questions)
  • Re: problem of openSSH and certificate in UTF8
    ... I extract the DN of the server certificate with the command: ... > However, when the client connects to the remote ssh server and performs server authentication, the following error message appears: ... >No RSA+cert host key is known for 10.144.166.135 and you have requested strict checking. ...
    (SSH)
  • Re: dcdiag - advertising errors on newley promoted domain controller
    ... Can you do the following on uksccmads01 ... The problem may actually have nothing to do with the new server but the ... From a command prompt try and see if you get any additional info ... Skipping site UK-CCM, this site is outside the scope ...
    (microsoft.public.windows.server.active_directory)