SoFunction
Updated on 2025-03-02

How to establish ssh mutual trust between Linux

SSH mutual trust

Establish SSH mutual trust between Linux systems (also known as SSH key authentication)

Allows you to remotely log in to another Linux system without entering a password

step

1. Generate SSH key pairs on the local terminal

ssh-keygen -t rsa

All options default (direct enter), and two files id_rsa and id_rsa.pub will be generated in the ~/.ssh directory, where id_rsa is the private key and is saved locally;

id_rsa.pub is a public key that needs to be transmitted to a remote computer

2. Copy the local public key to the remote computer

Use the following command to copy the local public key to the remote computer.

Please replace port, user and host as the ssh port, user name and IP address on the remote computer respectively:

ssh-copy-id -i  ~/.ssh/id_rsa.pub -p port user@host

This will require you to enter the password for the remote computer.

After entering, your public key will be copied to the ~/.ssh/authorized_keys file of the remote computer.

3. Test SSH mutual trust

ssh -p port user@host

The above steps are required for both computers participating in mutual trust.

This successfully establishes SSH mutual trust between local and remote computers

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.