Home  >  Article  >  System Tutorial  >  Create SSH password-free login

Create SSH password-free login

WBOY
WBOYforward
2024-03-06 10:04:18882browse

Enter the text below

Ignore the ssh installation scp installation process. By default, the current machine and the remote machine are considered to have complete ssh and scp functions

First use the ssh-keygen -t rsa command in machine B (children who want to play git should know this~)

[hart02@hart02 .ssh]$ ssh-keygen -t rsa

Create SSH password-free login

Enter file in which to save the key (/home/hart02/.ssh/id_rsa)

Press the enter key directly

Enter passphrase (empty for no passphrase):

means please enter the password. If you do not enter it, there is no password. Of course, we use the enter key ~ and then re-enter the password. Be sure to keep it consistent twice~, if you don’t enter it the first time, you have to enter it the second time~

Note: The machine has already been generated, so the prompt says

/home/hart02/.ssh/id_rsa already exists.

After the input is completed, such an interface will appear (this interface is a screenshot regenerated on the test machine, and several key things have been highlighted)
Create SSH password-free login
From the picture above, we can understand that the generated public and private keys are stored in the /user/.ssh/ directory. user is the home directory of the currently logged in user.
Authorized_keys in the picture below will not be automatically generated. It is temporarily of no use in the current machine B

Create SSH password-free login

View the files in the .ssh directory

Now we operate in machine A, and the operation is consistent with the above steps. When the generation is completed, we touch a file named authorized_keys
Create SSH password-free login

Here comes the important part~~:

Use

in machine B
cat id_rsa.pub

Check the public key and then copy this string of things~
In machine A,

vim authorized_keys

Paste the copied content into this file on machine A.
ESC -> :wq! -> enter Save and exit
Create SSH password-free login

cat authorized_keys

Ensure successful writing

chmod 600 authorized_keys

Modify file permissions
Create SSH password-free login
After completing the above steps, be sure to do something

/etc/init.d/sshd restart

Restart the ssh service.
Create SSH password-free login

So far. SSH password-free login configuration is completed. That sounds nice, why not take a look at the effect:

Create SSH password-free login

OK, next chapter will explain the scp remote copy script~

The above is the detailed content of Create SSH password-free login. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:linuxprobe.com. If there is any infringement, please contact admin@php.cn delete