Paramiko SFTP autologon using id_dsa.pub

Discussion in 'Python' started by Mike Hjorleifsson, Feb 6, 2008.

  1. 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 ?
     
    Mike Hjorleifsson, Feb 6, 2008
    #1
    1. Advertising

  2. > 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. Löwis, Feb 6, 2008
    #2
    1. Advertising

  3. 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" <> 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
     
    Mike Hjorleifsson, Feb 6, 2008
    #3
  4. 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
     
    Martin v. Löwis, Feb 6, 2008
    #4
  5. 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" <> 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
     
    Mike Hjorleifsson, Feb 6, 2008
    #5
  6. 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-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
     
    Todd Whiteman, Feb 7, 2008
    #6
  7. > 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
     
    Martin v. Löwis, Feb 8, 2008
    #7
  8. 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-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
     
    Michele Hjorleifsson, Feb 14, 2008
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. B.W.

    Adding Pub any other way?

    B.W., Oct 3, 2003, in forum: HTML
    Replies:
    3
    Views:
    342
    Jukka K. Korpela
    Oct 3, 2003
  2. Edd
    Replies:
    2
    Views:
    325
  3. sa6113
    Replies:
    0
    Views:
    326
    sa6113
    Oct 22, 2008
  4. MaggotChild

    Net::SFTP Fails, sftp OK

    MaggotChild, Oct 28, 2009, in forum: Perl Misc
    Replies:
    2
    Views:
    1,018
    C.DeRykus
    Oct 29, 2009
  5. Kevin13
    Replies:
    3
    Views:
    963
    Kevin13
    Dec 1, 2009
Loading...

Share This Page