Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Using paramiko rsa key

Reply
Thread Tools

Using paramiko rsa key

 
 
loial
Guest
Posts: n/a
 
      02-10-2009
I want to connect via ssh from a python script on windows to an AIX
server running openSSH using rsa keys rather than a password.

Can anyone provide me with /point me at a simple tutuorial on the
steps I need to go though in terms of geneerating the key, installing
on the server and connecting in my python code?

Thanks in advance.



 
Reply With Quote
 
 
 
 
loial
Guest
Posts: n/a
 
      02-10-2009
Can anyone be a little more helpful than Tino?

I have generated the key file as follows on windows and ftp'd the
id_rsa.pub file to the .ssh directory on the server and renamed to
authorized_keys


import paramiko


key = paramiko.RSAKey.generate(204

key.write_private_key_file('Z:/id_rsa')
file = open('Z:/id_rsa.pub','w')
file.write("ssh-rsa " +key.get_base64())
file.close()

But when I try to connect as follows I get an authentication failed
error.


import paramiko

paramiko.util.log_to_file('demo_sftp.log')

try:
try:
key = paramiko.RSAKey.from_private_key_file("Z:/id_rsa") #the
generated private key
except Exception, e:
print str(e)
t = paramiko.Transport(('10.5.1.15', 22))
print "here"
t.start_client()
t.auth_publickey('prod2',key)

if t.is_authenticated():
print "Got it!"
sftp = paramiko.SFTPClient.from_transport(t)
dirlist = sftp.listdir('.')
print "Dirlist:", dirlist
t.close()
except Exception, e:
print str(e)
t.close()



 
Reply With Quote
 
 
 
 
Martin P. Hellwig
Guest
Posts: n/a
 
      02-10-2009
loial wrote:
> Can anyone be a little more helpful than Tino?

<cut>
I'll do some freebie hints
What I would do is try first whether key authentication works at all,
for example following a tutorial like
http://the.earth.li/~sgtatham/putty/.../Chapter8.html

And if that works translate it to the relevant python code.

--
mph
 
Reply With Quote
 
loial
Guest
Posts: n/a
 
      02-10-2009
On 10 Feb, 17:08, "Martin P. Hellwig" <martin.hell...@dcuktec.org>
wrote:
> loial wrote:
> > Can anyone be a little more helpful than Tino?

>
> <cut>
> I'll do some freebie hints
> What I would do is try first whether key authentication works at all,
> for example following a tutorial likehttp://the.earth.li/~sgtatham/putty/0.53b/htmldoc/Chapter8.html
>
> And if that works translate it to the relevant python code.
>
> --
> mph


Thanks..I'll try that first
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How add/change password for RSA priv key using PyCrypto k2 Python 0 08-01-2011 11:22 AM
paramiko public key eight02645999@yahoo.com Python 2 12-13-2006 11:43 AM
Implementing .net RSA on the server *and* JavaScript RSA on the client gg ASP .Net 0 11-18-2004 10:29 PM
Error using Crypt::OpenSSL::RSA - Fails loading public key - Help needed John Bergstrom Perl 0 08-03-2003 12:22 AM
Error using Crypt::OpenSSL::RSA - Fails loading public key - Help needed John Bergstrom Perl Misc 0 08-03-2003 12:21 AM



Advertisments