In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to achieve ssh password-free login configuration in Centos6.5". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
0. Description
For ease of illustration here, assume that there are two hosts An and B with centos6.5 installed. The goal is to realize that An and B hosts can log in to each other's hosts through ssh password-free respectively. The configuration process of different hosts is the same. The configuration process of host An is introduced here.
Create a password-free login user name on the AB host in advance, and add the hostname and ip to the / etc/hosts file.
Create a new user: useradd jay
Set the password: passwd jay, enter the password you want, and then su jay switch users
Modify the hostname: vim / etc/sysconfig/network, join hostname=master, and log out of the system to see that the modification is successful.
Modify the hosts file: vim / etc/hosts
192.168.88.101 master
192.168.88.102 slave1
1. Environment settin
1.1 turn off the firewall (root permissions)
Centos6.5 is very strict in network management and needs to shut down selinux. Under / etc/selinux/config, change SELINUX=enforcing to SELINUX=disabled. Root permission is required.
Bash/shell Code copies content to the clipboard
# su root
Password:
$vim / etc/selinux/config
Find SELINUX and change it to SELINUX=disable
1.2 modify the configuration file of sshd (root permissions)
Bash/shell Code copies content to the clipboard
$vim / etc/ssh/sshd_config
Find the following and remove the comment character "#"
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh / authorized_keys
1.3 restart the sshd service (root permissions)
Bash/shell Code copies content to the clipboard
$/ sbin/service sshd restart
two。 Generate public and private keys locally
Switch back from root to the user jay who wants to log in without a password, and execute the command.
Bash/shell Code copies content to the clipboard
# ssh-keygen-t rsa
By default, two files are generated in the user jay's home directory (~ / .ssh /):
Id_rsa: private key
Id_rsa.pub: public key
3. Import the public key into the authentication file
3.1 Import to this machine
Bash/shell Code copies content to the clipboard
# cat ~ / .ssh/id_rsa.pub > > ~ / .ssh/authorized_keys
Complete this step, and then follow step 4 to modify the relevant file permissions, you can log on to this machine without a password. You can enter the following command to verify.
Bash/shell Code copies content to the clipboard
Ssh localhost
If you can log in, the verification is successful.
3.2 Import to the target host
3.2.1 operate locally and transfer to the target host
Bash/shell Code copies content to the clipboard
# scp ~ / .ssh/id_rsa.pub root@ destination host ip or hostname: / home/id_rsa.pub
Note that when transferring files to the target host, use the root user, otherwise it will be denied because of insufficient permissions. After entering the target host password, the OK appears and the transfer is successful.
3.2.2 Log in to the target host and import the public key into the authentication file
Log in to the target host using the username jay that you want to log in without a password. Then do the following.
Bash/shell Code copies content to the clipboard
# cat / home/id_rsa.pub > > ~ / .ssh/authorized_keys
Then follow step 4 to modify the relevant file permissions to complete the password-free login settings.
4. Change the permissions of related files
Bash/shell Code copies content to the clipboard
# chmod 700 ~ / .ssh
# chmod 600 ~ / .ssh/authorized_keys
At this point, complete the password-free login settings.
5. test
Host A (jay@master), host B (jay@slave1). On host A, switch to the jay user and execute the following command test:
Ssh slave1
This is the end of the content of "how to implement ssh password-free login configuration in Centos6.5". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.