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

Create SSH password-free login

WBOY
Release: 2024-03-06 10:04:18
forward
919 people have browsed it

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
Copy after login

Create SSH password-free login

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

Press the enter key directly

Enter passphrase (empty for no passphrase):
Copy after login

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.
Copy after login

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
Copy after login

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

vim authorized_keys
Copy after login

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

cat authorized_keys
Copy after login

Ensure successful writing

chmod 600 authorized_keys
Copy after login

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

/etc/init.d/sshd restart
Copy after login

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!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template