Linux Sharing SSH Keys slightly confusing

I have a scenario that is slightly confusing to me.

I setup server A with cloud provider and gave SSH key for my Laptop and Workstation I can connect with these devices perfectly.

I have setup Server B with different cloud provider gave my SSH key for my Laptop and Workstation again I can connect perfectly with these devices.

Now I want Server A and Server B to communicate via SFTP so I can send files.

I am thinking I need to generate a SSH key on Server B and share it with Server A Via my Laptop as sharing SSH keys directly is not possible.

Can I get advice on the steps involved and where the SSH file are placed on each device for file transfer to work

Much apprenticed

2 Likes

Have a read:

HTH!

1 Like

Do you mean automatically / unattended? Or just being able to log-in to one and push/pull files to/from the other?

Ok as far as I understand you want to communicate from Server A => B via SFTP so in general uploading some files right? I would do the following (not tested):

  1. Generate a new SSH-Key on Server A:
    ssh-keygen -t ed25519

  2. Upload the public key to Server B:
    You could either use
    ssh-copy-id username@server_b
    or
    cat ~/.ssh/id_rsa.pub | ssh username@server_b "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys

  3. Server A is now able to login to Server B via it’s private key

find more information here How To Configure SSH Key-Based Authentication on a Linux Server | DigitalOcean