How to use Authorized Keys to Create a Passwordless SSH Connection
Warning: This post is over a year old. I don't always update old posts with new information, so some of this information may be out of date.
If you're accessing Linux servers or automating tasks between servers, rather than having to enter your user password every time, you can also use SSH public key authentication. This is a simple process that involves creating a local key and storing it within the authorized_keys file on the remote server.
- Check if you already have a SSH key.
$ ssh-add -L
- If you don't have one, create one.
- Upload the key onto the server. Replace myserver with the hostname or IP
address of your remote server.
$ ssh-copy-id myserver
If you're using Mac OS X and you don't have ssh-copy-id installed, download and
install Homebrew and run the
brew install ssh-copy-id command.
If successful, you should now see a message like:
Now try logging into the machine, with "ssh 'myserver'", and check in:
to make sure we haven't added extra keys that you weren't expecting.
Now the next time that you SSH onto the server, it should log you in without prompting you for your password.
About the Author
Oliver Davies is a Full Stack Web Developer and System Administrator based in the UK. He is a Senior Software Engineer and Technical Team Lead at Inviqa and a part-time freelancer specialising in Drupal, Symfony and Laravel development and Linux systems administration.