Sometimes we want to log in to SSH through another account, usually we need to re-enter the password when logging in. However, for some users who don't want to remember too many passwords, this is a bit of a hassle. How can I log in without entering a password?
Solution:
1. You need a user & ldquo; aliceA & rdquo; log on to the hostA.
2. Use ssh-keygen to generate a pair of rsa public and private keys. The generated key pair will be stored in the ~/.ssh directory.
$ ssh-keygen -t rsa
3. Use the following command to create the ~/.ssh directory under the aliceB user directory on the target host hostB. If the .ssh directory already exists on aliceB@hostB, this step will be skipped.
$ ssh aliceB@hostB mkdir -p .ssh
4. Copy the public key of user “aliceA” on hostA to aliceB@hostB to implement passwordless ssh.
$ cat .ssh/id_rsa.pub |
Ssh aliceB@hostB ‘cat 》 .ssh/authorized_keys’
Since then, you don't need to enter a password from ssh to aliceB@hostB on aliceA@hostA. (Small compilation Note: The above operation of creating a directory and copying can also be done in one step by an ssh-copy-id command: ssh-copy-id -i ~/.ssh/id_rsa.pub aliceB@hostB)
Troubleshooting
1. You may still need to enter your SSH password even after the key authentication is in effect. If this is the case, check the system log (such as /var/log/secure) to see if the following exception occurs.
Authentication refused: bad ownership or modes for file /home/aliceB/.ssh/authorized_keys
In this case, the key authentication failed due to the ~/.ssh/authorized_keys file The permissions or owner are incorrect. In general, this error occurs if the file is readable by all users except you. Change the permissions of the file in the following way to fix the error.
$ chmod 700 ~/.ssh/authorized_keys
The above is how to log in to the SSH server without entering a password in the Linux system. If you have a user who has encountered this situation, follow the above method to set it up.
In Linux system, if you want Vim editor to play a bigger role, you need to install some plug-ins for
In the Ubuntu system operation, sometimes the default startup program changes due t
We all know that cgroups in Linux system can be used to manage cpu resources. Today, Xiaobian wants
Some people say that Linux without a terminal is not a complete Linux system. This
Linux cancels the cp command to overwrite the file prompt method
Ubuntu defragmentation command summary
How to configure the permissions of the Linux system sudo command?
Does Linux use the ODBC method or the DBI way to install the R language extension package?
Linux tips for viewing directory content
Learn to use the character set encoding of tool conversion files in Linux systems
Ubuntu System Installation Tutorial How to Install Ubuntu System
How to use the history command in Linux
CentOS automatically starts the desktop service after booting
How to install JITwatch in Linux system?
Linux is a way to execute programs as other users.
Ubuntu install and switch Nvidia dual graphics driver method
Usb mouse unrecognized solution
How to make "user folder" under windows 7 set to non-system disk
How to query Win10 computer DNS address? Win10 computer query DNS address two ways
How to view hidden files in Win10 system? Win10 view hidden file method
Share the latest method of installing windows 7 under XP system
Novice entry: the difference between 32-bit and 64-bit Windows 7 and WIN XP (2)
Let Win7 right-click menu no longer very long skills
Win8 system does not recognize the optical drive solution