#!/bin/bash
#---------------设置ssh免密登入---------------#
HOST_IP_NODE=10.0.0.31
HOST_PASS_NODE=0000
#安装expect软件包
yum install expect -y
expect << EOF
set timeout 5
spawn ssh-keygen -t rsa
expect "id_rsa):"
send "\r"
expect "passphrase):"
send "\r"
expect "again:"
send "\r"
expect eof
EOF
expect << EOF
set timeout 5
spawn ssh-copy-id root@$HOST_IP_NODE
expect "(yes/no)?"
send "yes\r"
expect "password:"
send "$HOST_PASS_NODE\r"
expect eof
EOF
ssh免密登入脚本实现
最新推荐文章于 2024-06-18 11:29:00 发布