Ssh authentication in CentOS, requiring no password to log on to another machine

Source: Internet
Author: User
Tags ssh server
In linux, ssh authentication is used, and access to another machine without a password is usually used to log on to another machine through ssh. ssh authentication is performed on each machine, in this way, you do not need to enter a complicated password every time. I think the key to this problem today is that I want to get it from a remote server through rsync...

Use ssh authentication in linux without entering a password to access another machine

In work, ssh authentication is usually performed on each machine that logs on to another machine through ssh, so you do not need to enter a complicated password every time.

The key to this problem I remembered today is that I want to obtain data from the remote server through rsync to the client.

Because you need to enter the password for rsync through ssh, in order to make the scheduled task run smoothly without entering the password manually, I performed ssh authentication.

 

Generate public and private keys on the client

# Ssh-keygen [press enter all the time]
Generating public/private rsa key pair.
Enter file in which to save the key (/root/. ssh/id_rsa ):
Enter passphrase (empty for no passphrase ):
Enter same passphrase again:
Your identification has been saved in/root/. ssh/id_rsa.
Your public key has been saved in/root/. ssh/id_rsa.pub.
The key fingerprint is:
A2: e5: ca: 9a: 55: 45: 16: e5: 40: ff: 7c: c3: 9b: 20: ef: 36 root @ XKWB5510

 

The generated public key and private key are in the following Directory :~ /. Ssh/[/root/. ssh]

# Ls ~ /. Ssh/
Id_rsa id_rsa.pub known_hosts

 

Public Key: id_rsa.pub

Private Key: id_rsa

 

Next, configure the private key to machines on other servers.

If this directory does not exist, then mkdir-p/root/. ssh

Edit the file/root/. ssh/authorized_keys

And write the public key to the file www.2cto.com.

Restart ssh service sshd restart if necessary

Check whether the sshd process already exists after the restart.

 

After the preceding settings are complete, you need to test whether the configured rules take effect:

Ssh server from client side

If the following message appears: Are you sure you want to continue connecting (yes/no )?
The setting is not successful.

If a prompt is displayed: Last login: Mon Sep 19 17:00:06 2011 from

Indicates that the setting is successful.

 

Finally, let's test whether the combination of rsync and ssh has taken effect. If no password is entered, the operation is successful.

] # Rsync-v-a-H -- progress-e ssh-u root @ SERVERIP:/home/wwwlog/www.pcstars.com _ access. log/home/sysadmin/zhaoyj/tg. nginx. log/234. pcstars_access.log
Refreshing ing file list...
1 file to consider
Www.pcstars.com _ access. log
29948965 100% 90.96 MB/s 0:00:00 (xfer #1, to-check = 0/1)

Sent 31056 bytes encoded Ed 3303276 bytes 2222888.00 bytes/sec
Total size is 29948965 speedup is 8.98

 

Succeeded

From: ANLJF's column

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.