ssh logo ssh: keys

1 2 3 4 5 6 7 8 9
Notes

If we don't want to use passwords we can set up "keys" that can authenicate us. This is a preferable way of going about SSH since it automates some of the error-prone parts of making the connection.

You'll first need to create a public and a private file. All of this is handled by the following command in the terminal:

ssh-keygen

You'll be prompted to create a filepath. We used /Users/vincent/.ssh/id_demo_purposes but you're free to pick another name. The main thing that's important is that you point to a path that is in your home .ssh folder. After the command is done you should have generated two files, which can be varified via ls.

ls id_demo*

This command should show a id_demo_purposes (private) file and a id_demo_purposes.pub (public) file.

Configure

Now that you've gotten your keys set up locally, it's time to move it to the other server. The command you'll want for this uses the following convention;

ssh-copy-id -i <path-to-private-file> <username>@<ip-adr>

In our case, this evaluated to;

ssh-copy-id -i /Users/vincent/.ssh/id_demo_purposes vincent@192.168.1.36

You'll need to give your password one more time, but after that ... you're all set!

SSH

You should now be able to connect via;

ssh -i /Users/vincent/.ssh/id_demo_purposes vincent@192.168.1.36

No password needed.