Set up SSH password-free logon script (Hadoop Automation deployment script one)

Source: Internet
Author: User

<title>Set up SSH password-free logon script (Hadoop Automation deployment script one)</title> Set SSH password-free login script (fly Yungu Big Data Automation Deployment script I)
1.#!/bin/sh
2.#important Note:This script was expected to run on master node
3.Pwd=hdp
4.User=hdp
5.Sshdir=/home/dhp/.ssh
6.
7.#create temp dir to store id_pub file
8.Mkdir$SSHDIR/sshtmp
9.
.host= (master slave01 slave02);
One by one .
. forHOSTinch ${hosts[*]}
. Do
. #clear Files
A .Sshpass-p$PWDSsh$USER@$HOSTRm- F $SSHDIR/authorized_keys
.Sshpass-p$PWDSsh$USER@$HOSTRm- F $SSHDIR/id_rsa
.Sshpass-p$PWDSsh$USER@$HOSTRm- F $SSHDIR/id_rsa.pub
.
. #generatee key pair on "HOST"
.Sshpass-p$PWDSsh$USER@$HOST "ssh-keygen-t rsa-p \" \ "f \"$SSHDIR/id_rsa\ ""
.
. #copy Pub key to master node collectively
.Sshpass-p$PWDSsh$USER@$HOST "Sshpass-p $PWD SCP $SSHDIR/id_rsa.pub $USR@master:$SSHDIR/sshtmp"
A .
.Cat$SSHDIR/sshtmp/id_rsa.pub >>$SSHDIR/authorized_keys
. Done
.
.#remove Temporary dir
.Rm- FR$SSHDIR/sshtmp
.
.#must ensure the file permission
.chmod644 $SSHDIR/authorized_keys
.
.#distribute Authorized_keys to all nodes
. forHOSTinch ${hosts[*]}
. Do
The PNs.Sshpass-p$PWDScp$SSHDIR/authorized_keys$USR@$HOST:$SSHDIR
. Done

Set SSH password-free logon script (Hadoop Automation deployment script one)

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.