Not sure if the question I'm asking is correct but basically I wanted to automate this process
scp ~/.ssh/id_rsa.pub username@example.com:~/
ssh username@example.com
mkdir .ssh
cat id_rsa.pub >> .ssh/authorized_keys
rm id_rsa.pub
chmod go-w ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
So I thought I could create a shell script and put it in my .bash_profile like this:function
setup_ssh () {
scp ~/.ssh/id_rsa.pub $1:~/
ssh $1
#the following is happens when connected to the server using ssh
mkdir .ssh
cat id_rsa.pub >> .ssh/authorized_keys
rm id_rsa.pub
chmod go-w ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
}
But of course this doesn't work because it doesn't continue the commands once connected to the server. Is there any way to continue the commands once it's connected to the server via ssh?
ssh-copy-id
as shown by forcefsck, it's exactly suited for this task. – Gilles 'SO- stop being evil' Jan 22 '12 at 23:05