加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

服务器免密登陆脚本

发布时间:2020-12-15 23:25:12 所属栏目:安全 来源:网络整理
导读:yum install -y tcl tclx tcl-devel wget http://sourceforge.net/projects/expect/files/Expect/5.45/expect5.45.tar.gz/download tar xzvf download cd expect5.45 ./configure make make install ln -sf /data/expect5.45/libexpect5.45.so ? /usr/lib64/

yum install -y tcl tclx tcl-devel

wget http://sourceforge.net/projects/expect/files/Expect/5.45/expect5.45.tar.gz/download

tar xzvf download

cd expect5.45

./configure

make && make install

ln -sf /data/expect5.45/libexpect5.45.so? /usr/lib64/libexpect5.45.so

expect

?

vim autossh.sh

?

#!/usr/bin/expect

set timeout 10?

set username [lindex $argv 0]

set password [lindex $argv 1]

set hostname [lindex $argv 2]

spawn ssh-copy-id -i /root/.ssh/id_rsa.pub $username@$hostname

expect {

? ? "*assword" {send "$passwordr";}

? ? "yes/no" {send "yesr";exp_continue}

}

expect eof

?

chmod +x autossh.sh

?

./autossh.sh root password ip

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读