the one python book
newbie question: Is there a 'K&R" type of Python book? The book that you'd better have on your shelf if you are going into Python? -- http://mail.python.org/mailman/listinfo/python-list
Q: paramiko/SSH/ how to get a remote host_key
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
Re: How to use py2exe ...
Here is how I am creating my win32 exe with py2exe: 1. create a setup.py file with the following: from distutils.core import setup import py2exe #setup(console=['main_script.py']) setup(windows=['main_script.py'] ) 2. run the following command from console: 'python setup.py py2exe' Hope this helps. On Jan 21, 9:45 am, Santiago Romero <[EMAIL PROTECTED]> wrote: > Hi... > > I'm a Linux user, and I would like some windows-friends to test a > game I'm writing with python+pygame without they needing to install > python, pygame, and so on. > > I've heard about py2exe and pygame2exe, but I'm not sure on how to > use them to create: > > a.- standalone exe files with a single .py program. > Example: myprogram.py > > or > > b.- exe files containing all my source code + data directories (png > files, data files, and so). > Example: main.py, doc/README, src/*.py and data/* > > The problem is I'm not sure on how to use py2exe and pygame2exe to > build the executables... > > And finally, a question: if I want to provide source code > separately ... can I include .pyc files instead of .py files? -- http://mail.python.org/mailman/listinfo/python-list
Re: Q: paramiko/SSH/ how to get a remote host_key
I am connecting from a WindowsXP SP2 machine. When using Putty as an
SSH client, if you connect for the first time then you get somethign
like this:
''' The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 1024 7b:e5:6f:a7:f4:f9:81:62:5c:e3:1f:bf:8b:57:6c:5a
If you trust this host, hit Yes to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, hit No.
If you do not trust this host, hit Cancel to abandon the
connection. '''
If I get it correctly, Putty is using such a command to recieve the
host_key the first time it connects to a remote SSH server. Then it
stores it into the registry. The question is how can I do it from
Python?
Guilherme Polo wrote:
> 2008/1/21, DHR <[EMAIL PROTECTED]>:
> > 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
--
http://mail.python.org/mailman/listinfo/python-list
Re: Q: paramiko/SSH/ how to get a remote host_key
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()
On Jan 21, 3:10 pm, "Guilherme Polo" <[EMAIL PROTECTED]> wrote:
> 2008/1/21, DHR <[EMAIL PROTECTED]>:
>
>
>
> > I am connecting from a WindowsXP SP2 machine. When using Putty as an
> > SSH client, if you connect for the first time then you get somethign
> > like this:
>
> > ''' The server's host key is not cached in the registry. You
> > have no guarantee that the server is the computer you
> > think it is.
> > The server's rsa2 key fingerprint is:
> > ssh-rsa 1024 7b:e5:6f:a7:f4:f9:81:62:5c:e3:1f:bf:8b:57:6c:5a
> > If you trust this host, hit Yes to add the key to
> > PuTTY's cache and carry on connecting.
> > If you want to carry on connecting just once, without
> > adding the key to the cache, hit No.
> > If you do not trust this host, hit Cancel to abandon the
> > connection. '''
>
> > If I get it correctly, Putty is using such a command to recieve the
> > host_key the first time it connects to a remote SSH server. Then it
> > stores it into the registry. The question is how can I do it from
> > Python?
>
> When you call method connect of SSHClient it checks if server's
> hostname is in system_hot_keys or any local host keys, if it is not,
> the missing host key policy is used. The default policy is to reject
> the key and raise an SSHException, but you can change that default
> policy to AutoAddPolicy
>
>
>
>
>
> > Guilherme Polo wrote:
> > > 2008/1/21, DHR <[EMAIL PROTECTED]>:
> > > > 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
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> --
> -- Guilherme H. Polo Goncalves
--
http://mail.python.org/mailman/listinfo/python-list
