linux 脚本自动输入密码

linux 安装expect

yum install -y expect

编辑脚本 expect.sh

#!/usr/bin/expect
set timeout 1
spawn ssh 10.226.3.14
expect "*password:"
send "N0IjoiIn09gjmP59gjm532f01b1\r"
interact

另一个方法:

yum -y install sshpass

#!/bin/bash
sshpass -p 'N0IjoiIn09gjmP59gjm532f01b1' ssh -p 22 root@10.226.3.14

搞定。

posted @ 2022-04-13 15:02  a戴姆勒  阅读(771)  评论(0编辑  收藏  举报