Re: [SLUG] automating bash password entry

From: Ian Blenke (icblenke@nks.net)
Date: Thu Apr 22 2004 - 17:13:23 EDT


Austin Theen wrote:
> I suppose one of the craftier linux dieties will chime in about how you
> can do this in a 3 line perl script.

        adminbox$ cd ~/.ssh
        adminbox$ ssh-keygen -t dsa -b 1024 -P '' -f id_dsa
        adminbox$ scp id_dsa.pub root@userbox:.ssh/authorized_keys

The scp will ask for your password. From now on, from that user on
adminbox, you can ssh into userbox as root without a password using ssh
key trust.

        adminbox$ ssh root@userbox
        userbox#

You may add multiple keys to a remote box merely by cat'ing them to the
end of authorized_keys:

        mybox$ ssh-keygen -t dsa -b 1024 -P 'mypassword' -f id_dsa
        mybox$ cat id_dsa.pub | \
               ssh root@userbox 'cat - >> ~/.ssh/authorized_keys'
        mybox$ eval `ssh-agent`
        mybox$ ssh-add ~/.ssh/id_dsa
        Password: {mypassword}
        mybox$ ssh root@userbox
        userbox#

Now both your user on adminbox, and my user on mybox can ssh in as root
to userbox. My ssh key is protected with a passphrase of "mypassword",
which I allow ssh-agent to unlock so that I won't need to enter a
password to use my key when connecting to userbox.

I don't recommend leaving passphraseless SSH keys laying around - but
ssh-agent/ssh-add is something most newbies don't seem to grasp right away.

-- 
- Ian C. Blenke - Director of Service Delivery <icblenke@nks.net>
(This message bound by the following:
http://www.nks.net/email_disclaimer.html)
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS).  Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:41:20 EDT