Difference between revisions of "Ssh with a private-public key"
(→Turnink the keys and identities on and off) |
|||
Line 18: | Line 18: | ||
Done! |
Done! |
||
== |
== Turning the keys and identities on and off == |
||
You may want to use the following commands or even define aliases as below. Note, ssh -t <seconds> sets timeout for the open key. In the example below 10800 = 3 hours. |
You may want to use the following commands or even define aliases as below. Note, ssh -t <seconds> sets timeout for the open key. In the example below 10800 = 3 hours. |
||
Line 24: | Line 24: | ||
alias keyoff='ssh-add -D' |
alias keyoff='ssh-add -D' |
||
alias keylist='ssh-add -l' |
alias keylist='ssh-add -l' |
||
== Other links and info == |
== Other links and info == |
Revision as of 23:19, 22 July 2010
If you are using svn+ssh or just want automatic login without typing the password whenever using ssh, you may want to consider setting up public-private key authentication between the client and server machine. The server will have the public key, and the client will have the private key. This is how to set it up:
On the client: generate the public/private key pair
cd ~/.ssh ssh-keygen -t dsa
Copy the public key to your server, and add to ~/.ssh/authorized_keys file, like this
scp ./id_dsa.pub user@myserver.com: ssh user@myserver.com myserver> cat id_dsa.pub >> .ssh/authorized_keys myserver> rm id_dsa.pub myserver> logout
Remember to check that your .ssh/ directory and files in there are not public readable, otherwise someone may steal your private key and get access to your server!
Done!
Turning the keys and identities on and off
You may want to use the following commands or even define aliases as below. Note, ssh -t <seconds> sets timeout for the open key. In the example below 10800 = 3 hours.
alias keyon="ssh-add -t 10800" alias keyoff='ssh-add -D' alias keylist='ssh-add -l'