Linux uses SSH public key to implement bulk-free distribution Management Server

Source: Internet
Author: User

SSH login with no password to use the public and private keys. Linux can use Ssh-keygen to generate public/private key pair, below I take CentOS 6.6 as an example.

Management machine Extranet IP10.0.0.61 (intranet 172.16.1.61) server external network 10.0.0.31, port 52113, intranet 172.16.1.31

(1) First batch creation of administrative users on all machines.

[[Email protected] ~] #useradd oldgirl

[[Email protected] ~] #echo 123456|passwd--stdin oldgirl

[[Email protected] ~] #id oldgirl

(2) All machines are switched to the administrative user and a key pair is created.

[[Email protected] ~] #su –oldgirl

[[Email protected] ~] $ssh-keygen-t DSA #-t Specifies the key type, by default RSA, three consecutive enter

Your identification has been saved IN/HOME/OLDGIRL/.SSH/ID_DSA

Your public key has been saved In/home/oldgirl/.ssh/id_dsa.pub

[[Email protected] ~] $pwd

/home/oldgirl

[[Email protected] ~] $ll. ssh/

-RW-------1 oldgirl oldgirl 668 Mar 19:40 ID_DSA

-rw-r-----1 Oldgirl oldgirl 601 Mar 19:40 id_dsa.pub Lock

or use the following command to create a key pair with a non-interactive one-click

1 , Ssh-keygen-t dsa-p "-F ~/.SSH/ID_DSA >/dev/null 2>&1

2 , [[email protected] ~]$ echo-e "\ n" |ssh-keygen-t dsa-n ""

(3) Distributing secret keys (locks) to machines requiring management

[Email protected] ~]$ ssh-copy-id-i ssh/id_dsa.pub "-p 52113 [email protected]" Note this is the intranet segment, the port has been modified to 52113. The copy here is for the public key only, and it does not send the private key. Alternatively, you can use Scp-p to replicate remotely.

If the port is not modified, then you can use [[email protected] ~] $ssh-copy-id-i. ssh/id_dsa.pub [Email protected], this is the outside network segment.

(4) After distributing the key, you can go to the client (server) to view the public key information and permissions

[[Email protected] ~] $ll. ssh/
-RW-------1 oldgirl oldgirl 601 Mar 19:56 Authorized_keys #权限为600, sent over to the file renamed Authorized_keys, this is the SSH configuration file (/etc/ssh/s shd_conf) is set.

(5) Test: Remote use command to view server Nic

[[Email protected] ~] $ssh-p52113 [email protected]/sbin/ifconfig eth0

Eth0 Link encap:ethernet HWaddr 00:0c:29:85:5e:85

inet addr:10.0.0.31 bcast:10.0.0.255 mask:255.255.255.0

At this point, the initial implementation of using the SSH public key to implement a free batch distribution Management Server.

Linux uses SSH public key to implement bulk-free distribution Management Server

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.