Make a ssh connection to the server once, and no password is required for subsequent connections

First, we generate id_rsa locally. The t parameter means to specify the encryption type. The default is rsa, but the t parameter can be omitted.

ssh-keygen -t rsa -C "[email protected]"

Then go to ~/.ssh to execute vim config, paste the following content into it, and modify it according to your actual situation

Host dockerHub
    Hostname 111.196.145.8
    User smith
    Port 1323
    IdentityFile ~/.ssh/id_rsa

After saving and exiting, you can use the following command to connect to the server, but every time you need a password, we need to enter the following command every time we no longer need to enter the password, the effect of directly logging in to the server

ssh dockerHub

Next, id_rsa is also generated on the server, and the above ssh-keygen command is executed

At this time we execute in the local shell

sftp dockerHub

Enter yes for the first connection, save the fingerprint, and enter the password.

After logging in to the server with sftp, we first check which directory of the server we have logged in through pwd, and enter the .ssh directory of the home directory through the cd command, and see the id_rsa and id_rsa.pub files of the server.

We execute lpwd to see which directory is in the local area, and the prefix l means local.

We enter the .ssh of the local home directory through lcd

Make sure that both the local and the server are in the .ssh directory of the home directory, you can confirm again through pwd and lpwd

carried out

put id_rsa.pub authorized_keys

This sentence means to upload the id_rsa.pub of the local current directory to the current directory of the server and name it authorized_keys

At this time, we execute the exit command to exit the server, and then execute

ssh dockerHub

I found that it is directly connected to the server. If you find this article useful, please use your wealthy little hand to like it.

Guess you like

Origin blog.csdn.net/u012149637/article/details/112872938