Paramiko SFTP autologon using id_dsa.pub

  • Thread starter Mike Hjorleifsson
  • Start date
M

Mike Hjorleifsson

I wrote a lil module using paramiko's module to send a file via
sftp.. it works great using the username and password.
I would prefer to use id_dsa.pub to have an autologon and not save
the
password anywhere on the disk.. I cant find a good example of this.
Can anyone help ?
 
M

Martin v. Löwis

I wrote a lil module using paramiko's module to send a file via
sftp.. it works great using the username and password.
I would prefer to use id_dsa.pub to have an autologon and not save
the
password anywhere on the disk.. I cant find a good example of this.
Can anyone help ?

When you have an ssh-agent running that has the key loaded, paramiko
will automatically use that. If you don't have an ssh-agent running,
you have to pass either the pkey or the key_filename argument; the
former should be a PKey object (either RSAKey or DSSKey).

Regards,
Martin
 
M

Mike Hjorleifsson

Thanks for the response, is there an example bit of code somewhere i
could digest ?
 
M

Martin v. Löwis

Mike said:
Thanks for the response, is there an example bit of code somewhere i
could digest ?

I did

c.connect("<hostname>",username="loewis")

with ssh-agent, and it worked just fine.

Regards,
Martin
 
M

Mike Hjorleifsson

sorry i meant a code example that i pass the id_dsa.pub file contents
too
so i am not reliant on the host system to have the ssh-agent.
 
T

Todd Whiteman

Mike said:
I wrote a lil module using paramiko's module to send a file via
sftp.. it works great using the username and password.
I would prefer to use id_dsa.pub to have an autologon and not save
the
password anywhere on the disk.. I cant find a good example of this.
Can anyone help ?

Hi Mike,

If you download the Paramiko zip archive:
http://www.lag.net/paramiko/download/paramiko-1.7.2.zip

You can find examples of loading and using public/private keys for
automated logins in the code under the "demos" sub folder.

Cheers,
Todd
 
M

Martin v. Löwis

sorry i meant a code example that i pass the id_dsa.pub file contents
too
so i am not reliant on the host system to have the ssh-agent.

c.connect("<host>",username="loewis",key_filename=".ssh/identity")

works for me with ssh-agent disabled.

Regards,
Martin
 
M

Michele Hjorleifsson

wow been going nuts here after cutting and pasting to get a working test
so i ran demo.py ... and its not me.. i changed the hostname for
obvious reasongs, the id_dsa file does exist. i can sftp from bash no
problem. there is NO password on the key

Any ideas ? here is what i get.

Hostname: xxx.example.com
*** Host key OK.
Username [root]: isoaccpc2
Auth by (p)assword, (r)sa key, or (d)ss key? [p] d
DSS key [/root/.ssh/id_dsa]:
*** Caught exception: paramiko.SSHException: Channel closed.
Traceback (most recent call last):
File "demo.py", line 163, in ?
chan.get_pty()
File "build/bdist.linux-i686/egg/paramiko/channel.py", line 156, in
get_pty
File "build/bdist.linux-i686/egg/paramiko/channel.py", line 1062,
in _wait_for_event
SSHException: Channel closed.
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top