ssh passwordless login

  1. 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
  2. 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
  3. 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.
    #!/bin/sh
    ssh `basename $0` $*
  4. 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
  5. You can now perform ssh logins quickly simply. Substitute the server name you used in step four above.
    $ server

    You can also execute commands on the target machine. Example:
    $ server uptime

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options