How do I permanently add an identity for SSH?
Generate your key like normal: ssh-keygen
, then place that key to the remote server with ssh-copy-id
, which will sync it to the remote server's accepted keys.
ssh-keygen
ssh-copy-id user@host
It will prompt for your password then perform all the steps necessary to link your .pub
key with the remote SSH server.
By default it will copy all your .pub keys to the remote server. If you just created your key with ssh-keygen
then this isn't a problem (because you only have one!). However, if you have multiple keys you can copy just a specific key with the -i
flag.
ssh-copy-id -i ~.ssh/key_name.pub user@host
Replacing key_name.pub
with the name of the key.
put this in your ~/.bashrc
eval $(ssh-agent)
ssh-add ~/.ssh/where_ever_privake_key_is
You can generate a ssh key with the command:
ssh-keygen
Then you can copy your key to the server with:
ssh serveruser@servername "echo `cat ~/.ssh/id_dsa.pub` >> ~/.ssh/authorized_keys"
Now you can automatically log in your webserver