The authme, ssh key, bash function

Often it can be a pain to remember all the username/password combinations for all the different servers we touch in our day to day development.  I’ve come to really like this lil’ bash function given to me by my co-worker Anthony DiGirolamo.

1
2
3
function authme {
  ssh $@ 'cat >>.ssh/authorized_keys' < ~/.ssh/id_rsa.pub
}

Just put it in your ~/.bash_profile file or one of the other bash settings files you may be using.

Usage is like so

1
authme deploy@www.somedomain.com

You’ll be prompted for your password then returned to the local terminal prompt. This will ssh onto the given server and concatenate your ssh public key to the authorized_keys file. Allowing you from there on out, not having to supply a password to get on the server through ssh. Good stuff

Comments

Medical Jobs May 15, 2010 at 7:30 pm
Great information! I’ve been looking for something like this for a while now. Thanks!
mitroshin July 13, 2010 at 4:10 pm
I want to quote your post in my blog. It can? And you et an account on Twitter?
Irish July 18, 2010 at 4:15 pm
Ya no problem, and my username on Twitter is @supairish, but FYI, I don't post too often. Thanks for reading! :-)
Beau September 10, 2014 at 11:22 pm
I can't tell you how many times I've looked this up "authme irish" haha! Still use this to this day...probably should have my own .profile to use by now...but alas...I'm a nomad. LOL
Irish September 11, 2014 at 12:11 pm
Haha, nice Beau, glad it's of help to someone out there!