To log in to a Linux system, you need to use a password. Is there any way to log in to the system without using a password? The following small series will introduce you how to use rsa password-free login in ssh to log in to Linux, let's learn together.
A local host (i.e., for controlling other host machines);
(i.e. Server machine control) B is a remote host, if ip is 172.24.253.2;
Commands on A:
The code is as follows:
ssh-keygen -t rsa
(Three consecutive carriage returns, which are generated locally Public key and private key, no password is set, the generated public key private key is in the ~/.ssh directory, id_rsa is the private key, id_rsa.pub is the public key)
The code is as follows:
ssh "a href=“mailto:[email protected]”"[email protected]"/a"
mkdir .ssh
chmod 700 .ssh
(You need to enter a password, Note: You must set the permissions of .ssh to 700)
The code is as follows:
scp ~/.ssh/id_rsa.pub "a href=“mailto :[email protected]:~/.ssh”"[email protected]:~/.ssh "/a"
Then create the authorized_keys file on the server:
The code is as follows:
touch ~/.ssh/authorized_keys
Chmod 600 ~/.ssh/authorized_keys
(Note: The permissions of ~/.ssh/authorized_keys must be changed to 600. This file is used to save the public key generated by the ssh client. You can modify the ssh service of the server. End configuration file /etc/ssh/sshd_config to change the file name, the default is called authorized_keys)
The code is as follows:
cat id_rsa.pub 》 authorized_keys
# (will The content of id_rsa.pub is appended to authorized_keys, be careful not to use ", otherwise the original content will be emptied so that others cannot log in using the original key."
Back to A:
Code is as follows:
# ssh "a href=“mailto:[email protected]”"[email protected]"/a" (No password required, login successful)
From the surface, a brief understanding of the login process,
First, the ssh-keygen -t rsa command generates a key and a public key, and the key can set its own password
can understand the key as a key, the public key is understood as this The key corresponding to the lock,
put the lock (public key) on the server you want to control, lock the server, only the person with the key (key) can open the lock, enter the server and Control
And for the person who owns the key, you must know the password of the key itself to use the key (unless the key is not set), so that the key can be prevented. The key is copied.)
More concise way:
Step 1. If there is no authorized_keys file on the server: (If there is, skip this step)
Code As follows:
ssh "a href=“mailto:[email protected]”"[email protected]"/a"
mkdir .ssh
chmod 700 .ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
Step 2, in the machine:
Code As follows:
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub "a href=“mailto:[email protected] .253.2”"[email protected]"/a"
ssh-keygen -t rsa #Next three times, no password. Just fine.
Note: ssh-copy-id automatically appends the key to the remote host's .ssh/authorized_key
The above is the way to use rsa password-free login in ssh under Linux. Using this method, you can log in to the machine. Is it convenient? Try it now.
libvirt is a virtualization tool under Linux that supports various virtual machine monitors. How do
Usually the network card name is automatically recognized by the system and exists
In the CentOS 6 system, the boot partition is deleted due to carelessness or operat
Now that the Internet is developing at a high speed, the desktop application enviro
Linux uses S3QL to create an encrypted file system
What should I do if the Linux runlevel is set to 6 and then restart infinitely?
Ubuntu compile and install Hypertable method
What should I do if the Fedora 18 DNSenum shows IP garbled?
Tips for optimizing Mysql runtime environment on Linux
What should I do if Linux vi is stuck?
How to install boost library in Linux system
What should I do if the syntax of the Linux Vi editing code is not colored?
Linux using LGOGDownloader to download GOG games skills
Baidu network disk bcloud common problem solution in Linux
Win 7 genuine system query for more detailed authorization information
Win8 operation skills Daquan (a)
Win7 computer locks computer shortcuts
How to remove the win8 desktop icon shortcut small arrow?
Xp system is too slow how to do?
CAD conversion to word, excel graphic tutorial
Several special attempts to install Wubi (2)
A special recipe for cleaning up the history of the start menu
Rapid development of domestic remote control software industry
Alibaba Cloud Linux server to modify the root management password tutorial