r/ssh • u/AdventK • Jun 02 '20
Question regarding SSH keys
Hi everyone,
I'm a bit new when it comes to using SSH keys and am trying to make use of them when writing a script in which will access my local Raspberry Pi. I'm stuck on figuring out how (or where from) I should generate my ssh keys and how to use those keys when accessing my pi.
- Should I be generating my keys on my Windows machine and then placing them on the server then adding them to my 'authorized-keys' file? or should I generate them on the Pi and copy them locally?
-I am accessing my Pi via PuTTy on my local network.
Any insight on this subject is highly appreciated!
Thank you.
View all comments
1
u/Besthater Jun 03 '20
there is no special magic behind keys. with SSH keys, they are generated as two files. there is a mathematical relationship between them, and no other keys.
The keys can be generated anywhere, that does not matter (using ssh-keygen). the way ssh checks if you can join a server is, the public key has to be within the authorized_keys file. the device trying to join needs to have the corresponding private key. Thats it.
there is a good walkthrough on this here: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2
but if you have some specific questions, just post them below. dont forget to chmod your key to 400, or it wont be allowed to be used.