"Innovation comes only from readily and seamlessly sharing information rather than hoarding it."- Tom Peters
Development Blog

The Easy way for Key Based Authentication for SSH

Why use a key-based system?

Using a key-based system makes it much faster, and even more secure to ssh into a server, and scp files onto a remote server. To do this is pretty easy...


  1. On your local machine, create a .ssh in the home directory (if you don't have one already).
    mkdir ~/.ssh
  2. Go inside the folder.
    cd ~/.ssh
  3. Run the ssh-keygen command. This will create a set of public and private keys.
    When asked for the name, you can name it whatever you like. For example, I could name one michael_theirwinfamily_net for me to use on this site. When asked for the passphrases, feel free to leave them blank.
  4. Copy your public key to the server. Use the following command (replace the name of the public key with your real filename, and the host name with your real host)
    ssh-copy-id -i [path to .pub file] [remote-host]
    ssh-copy-id -i ~/.ssh/michael_theirwinfamily_net.pub michael.theirwinfamily.net
    You will need to enter your password to log in to the server, after which your key will be added!
  5. Now, ssh to your server, and you shouldn't need to enter your password!

Other ideas/troubleshooting

  • If you wish, you can use the same public key for various domains, hosts, etc.
  • Don't forget that if your username is not the same as the one you use on the server, use username@hostname for the [remote-host] part of the ssh-copy-id command. For example:
    ssh-copy-id -i ~/.ssh/michael_theirwinfamily_net.pub example@michael.theirwinfamily.net