jeroen.se
by jnieuwen
Setting your ssh public keys on a host
One of the things I often have to do when arriving at a new customer is adding my public keys on the hosts I have to work on. To simplify this process I use the following script:
#! /bin/sh
# Installs the jnieuwen ssh keys on an account.

mkdir $HOME/.ssh || exit 1
chmod u+rwx $HOME/.ssh || exit 1

cat $0 | sed "1,/^CUTFROMHERE/d" >> $HOME/.ssh/authorized_keys || exit 1

chmod og-rw $HOME/.ssh/* || exit 1
chmod og-rwx $HOME/.ssh || exit 1

exit 0
CUTFROMHERE
ssh-rsa AAAAB3Nz5[........]dtM0S4fdd
ssh-rsa AAAAB3Nza[........]A5F7lnhdD
So I just copy this script with scp to the host and then execute:
ssh <host> sh <script>
To use it just replace the SSH public keys after the CUTFROMHERE rule with your own.
0 comments

Nick:
Email:
Make your own addition with integers (needed to make sure you aint a spambot):
+ =
Categories
Cycling (2)
Gadgets (3)
IPv6 (1)
Misc (24)
Scripting (25)
Travel (7)
Unix (24)
Archive
January 2012 (1)
January 2011 (1)
November 2010 (1)
June 2010 (1)
April 2010 (2)
January 2010 (1)
December 2009 (1)
November 2009 (2)
May 2009 (1)
April 2009 (1)
March 2009 (1)
February 2009 (7)
January 2009 (3)
December 2008 (1)
November 2008 (4)
October 2008 (5)
September 2008 (1)
August 2008 (3)
July 2008 (2)
June 2008 (2)
May 2008 (3)
April 2008 (1)
March 2008 (1)
February 2008 (1)
January 2008 (4)
December 2007 (1)
November 2007 (7)
October 2007 (4)
September 2007 (1)
August 2007 (2)
June 2007 (6)
May 2007 (8)