This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
oliverdavies.uk-old-sculpin/source/_posts/2012-02-01-authorized-keys-passwordless-ssh.md

28 lines
1.2 KiB
Markdown
Raw Normal View History

2015-03-16 21:18:03 +00:00
---
title: How to use Authorized Keys to Create a Passwordless SSH Connection
slug: use-authorized-keys-create-passwordless-ssh-connection
tags:
2015-06-14 02:27:41 +00:00
- linux
- ssh
2015-03-16 21:18:03 +00:00
---
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.
1. Check if you already have a SSH key.
2015-06-14 02:27:41 +00:00
`$ ssh-add -L`
2015-03-16 21:18:03 +00:00
2. If you don't have one, create one.
2015-06-14 02:27:41 +00:00
`$ ssh-keygen`
2015-03-16 21:18:03 +00:00
2. Upload the key onto the server. Replace *myserver* with the hostname or IP address of your remote server.
2015-06-14 02:27:41 +00:00
`$ ssh-copy-id myserver`
2015-03-16 21:18:03 +00:00
If you're using Mac OS X and you don't have ssh-copy-id installed, download and install [Homebrew](http://mxcl.github.com/homebrew "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:
>
2015-06-14 02:27:41 +00:00
> ~/.ssh/authorized_keys
2015-03-16 21:18:03 +00:00
>
> to make sure we haven't added extra keys that you weren't expecting.
2015-06-14 02:27:41 +00:00
Now the next time that you SSH onto the server, it should log you in without prompting you for your password.