[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Paramiko SFTP autologon using id_dsa.pub

Mike Hjorleifsson

2/6/2008 4:23:00 AM

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 ?
7 Answers

Martin v. Loewis

2/6/2008 6:36:00 PM

0

> 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

Mike Hjorleifsson

2/6/2008 7:04:00 PM

0

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

On Feb 6, 1:35 pm, "Martin v. Löwis" <mar...@v.loewis.de> wrote:
> > 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

Martin v. Loewis

2/6/2008 8:10:00 PM

0

Mike Hjorleifsson wrote:
> 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

Mike Hjorleifsson

2/6/2008 10:30:00 PM

0

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.

On Feb 6, 3:09 pm, "Martin v. Löwis" <mar...@v.loewis.de> wrote:
> Mike Hjorleifsson wrote:
> > 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

Todd Whiteman

2/7/2008 5:26:00 PM

0

Mike Hjorleifsson wrote:
> 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...

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

Cheers,
Todd

Martin v. Loewis

2/8/2008 7:47:00 AM

0

> 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

Mike Hjorleifsson

2/14/2008 5:20:00 AM

0

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.


On Feb 7, 2008, at Thursday 7, 12:25 , Todd Whiteman wrote:

> Mike Hjorleifsson wrote:
>> 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...
>
> You can find examples of loading and using public/private keys for
> automated logins in the code under the "demos" sub folder.
>
> Cheers,
> Todd