ssh passwordless login
Mon, 07/14/2008 - 10:08am — Kevin
- Generate a public/private key pair in your dev environment. Hit enter to accept the defaults. You will only ever need to run this once ... proceed to step two if you've already done this.
$ ssh-keygen -t rsa
- Copy keys to remote server. Substitute server in the code below with your target machine.
$ ssh server "mkdir ~/.ssh; chmod 0700 ~/.ssh"
$ scp ~/.ssh/id_rsa.pub server:~/.ssh/authorized_keys2
If your appending a key from another machine that already has the authorized_keys2 file in place you can use the following instead (replace user@server with your info):
$ cat ~/.ssh/id_rsa.pub | ssh user@server "cat >> ~/.ssh/authorized_keys2"
- Create Turbo-mode ssh Login script and save in your PATH as ssh-to. You will only ever need to do this once ... proceed to step four if you've already done this.
ssh `basename $0` $*
- Setup symlinks. Substitute ~/bin for the PATH you saved the above script in. Substitute server for the server you copied your keys to in step 2.
$ ln -s ~/bin/ssh-to server
- You can now perform ssh logins quickly simply. Substitute the server name you used in step four above.
You can also execute commands on the target machine. Example:
$ server uptime