LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Confused on ssh key pairs (https://www.linuxquestions.org/questions/linux-newbie-8/confused-on-ssh-key-pairs-4175628182/)

chickenjoy 04-22-2018 07:39 AM

Confused on ssh key pairs
 
I have tested the following:
  1. user1@server1 - generate priv and pub keys
  2. i copy the pub key to user2@server2
  3. i can now login as user2@server2 with the need for a password.
  4. i did the opposite and the same logic applied.

What if i want to setup an SFTP server and i created a priv and pub key with user1@server1. and i want give give someone sftp access to user1 by using a key pair and not a password. I cannot request server2's public key and import it in mine; i want to give them a key that he can use to authenticate to server1. how can i achieve this?

Turbocapitalist 04-22-2018 07:55 AM

Each user+client+server tuple should have its own key pair.

Check "man ssh-keygen" for the -f and -C options. The -f allows you to give the files useful names and the -C allows you to put useful comments inside the key. That way you or they can have more than one key pair kicking around.

They can generate the key pair themselves:

Code:

cd ~/.ssh/
ssh-keygen -f server2_ed25519_key -t ed25519 -C "Oh this key is for somebody"

Be sure they enter a good passphrase for the key.

Then they can send you the file ~/.ssh/server2_ed25519_key.pub via e-mail or USB stick and you can install it in the user1 account at server1. The public key is public so you don't have to worry that much about keeping it hidden and e-mail is fine. The private key is a different matter and they should keep it very safe on their system.

michaelk 04-22-2018 08:50 AM

In addition you can have multiple public keys in the same users authorized_keys file.


All times are GMT -5. The time now is 03:45 AM.