How to set up SSH password-free login on Linux

Source: Internet
Author: User

I. SSH link on Linux

1. Function description

The SCP is security copy, which copies files or directories from one Linux system to another Linux system. SCP transmits data with SSH protocol, ensuring the security of data transmission, the format is as follows:

SCP remote User name @ip address: Absolute path to file local Linux system path

SCP local linux System file path remote user name @ip address: remote System file Absolute path name

The first format used for SCP is to copy a file or directory on a remote Linux system to a local Linux system, and the second is to copy a local file or directory to a path on a remote Linux system.

2. Example

(1) At present, we are in the IP "10.4.63.11" Linux system, planning to/home/ai/maintain/target/maintain-1.0-snapshot.war under the system

The files are copied to the/home/xdy/opt/directory under the Xdy user in the remote Linux system with IP "10.4.62.94" and renamed:

Scp/home/ai/maintain/target/maintain-1.0-snapshot.war [Email Protected]:/home/xdy/opt/maintain.war

When the command is entered, it is required to enter the password for the "10.4.62.94" Server Xdy, and then start copying the data remotely.

(2) Copy all files and subdirectories in the local/etc directory to the/opt directory under the root user of the remote Linux system with IP "10.4.62.94":

Scp-r/etc [email protected]:/opt

The option "R" here has the same meaning as the "r" option of the CP command.

Two. How to set up a password-free login

Prepare more than two Linux servers

First use SSH login to try, if not installed, you need to install first

SSH 10.4.63.11 will prompt you to enter your password

[[email protected] ~]$ ssh 10.4.63.11

[email protected] ' s password:

Last Login:mon Jan 9 10:40:29 from 10.4.16.200

Execute ssh-keygen-t RSA

At this point, the key-value pair for the private key and public key is generated under the SSH directory id_rsa,id_rsa.pub

Execute the same command generation file on the other server (take one for example)

[[email protected] ~]$ ssh-keygen-t RSA

Generating public/private RSA key pair.

Enter file in which to save the key (/HOME/AI/.SSH/ID_RSA):(all the way to the return)

Enter passphrase (empty for no passphrase):

Enter same Passphrase again:

Your identification has been saved In/home/ai/.ssh/id_rsa.

Your public key has been saved in/home/ai/.ssh/id_rsa.pub.

The key fingerprint is:

Da:7d:0c:8d:bf:ba:d5:0b:89:53:ea:cd:bc:a5:87:e7 [email protected]

The key ' s Randomart image is:

+--[RSA 2048]----+

| |

| |

| |

| o |

| S o O |

| O. B O |

| . . = B.O |

| . B.=o. |

| +ob=e |

+-----------------+

Merge public keys on all servers into one file Authorized_keys

Cat Id_rsa.pub >> Authorized_keys

SSH [email protected] cat/home/xdy/.ssh/id_rsa.pub >> Authorized_keys

See Authorized_keys has multiple server public key information, if you have more than one server in the same add to it.

Ssh-rsa aaaab3nzac1yc2eaaaabiwaaaqeav97+xzd2grlmq3tcamgn2gx8djbuq89f6h8a1za5golytj//jlmitjkw5c8/ b7hrrrsgsgvn8rhm7mcxdvjaipuqkwodydaqudjagcg4u5i0piz20du563odt6lgp5swzoqkdt0ah2uc4c+u8zdpi5uyw8ay+v60gydpzc+ bbs4twk1eqtkoagrhrkrcyxe11embfaf/ieva50c0tvw+pv9wudfby3f769bghx/hyp5mqvgntwjvtx5dj2vnydis7+mapgdm0ym34pf+ 7brvy4jpoxlxzjhpzohy1uxl+pbvscwxkhcsk+wnrkrnah/bq3hs5wczzwrc78l0yhggnq== [email protected]

Ssh-rsa aaaab3nzac1yc2eaaaabiwaaaqeawcavnhex5ezx2wpbrfwo2ycqeerhryj6eixeraq8ebvdbs+ 3aoyo3qutaijtkymx5jwkwcdtzow2wq8tkqotn9dedtb7gwhxpyif8qcxwpzxint92cjcgzssmhaor+ tqxupeej4ckeptuejoneaesioenj1ypbtevc9ms5hupxaig41lixfdcx6anjbyvgnozidf97hqe5rpy+ qmnbl2l5fazn7jwxakjmitx6rknzvs3k3swxk4524e8gplxed9vrkyeyt1zqhfy7plmer8lq2y9mtsrp0mj7uyfvvf8qqgwh+azjjmomtsn+ hsdpf3umxk9rbv3dyeewo41weaeq== [email protected]


Copy the Authorized_keys and known_hosts to the other server's. SSH directory

SCP Authorized_keys [Email protected]:/home/xdy/.ssh/

SCP known_hosts [Email protected]:/home/xdy/.ssh/

[email protected]. ssh]$ SCP Authorized_keys [email protected]:/home/xdy/.ssh/

[email protected] ' s password:

Authorized_keys 100% 787 0.8kb/s 00:00

[email protected]. ssh]$ SCP known_hosts [email protected]:/home/xdy/.ssh/

Known_hosts 100% 784 0.8kb/s 00:00

[email protected]. ssh]$

SSH login at this time, then no longer enter the password.

Scp/home/ai/maintain/target/maintain-1.0-snapshot.war [Email Protected]:/home/xdy/opt/maintain.war


This article is from "Dream Dreams" blog, please be sure to keep this source http://dreamy.blog.51cto.com/12471447/1890537

How to set up SSH password-free login on Linux

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.