Using paramiko rsa key

L

loial

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

loial

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(2048)

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()
 
L

loial

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

Thanks..I'll try that first
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top