Encryption 使用加密密码的SSH脚本
我使用以下脚本将SSH连接到一个带有wheel用户的服务器中。这是一个我想在许多服务器和应用程序中使用的测试脚本。但是,我不希望在脚本中以明文形式给出密码,而是希望在脚本运行时将其隐藏或加密,然后解密Encryption 使用加密密码的SSH脚本,encryption,ssh,expect,Encryption,Ssh,Expect,我使用以下脚本将SSH连接到一个带有wheel用户的服务器中。这是一个我想在许多服务器和应用程序中使用的测试脚本。但是,我不希望在脚本中以明文形式给出密码,而是希望在脚本运行时将其隐藏或加密,然后解密 #!/usr/bin/expect -f set timeout 2 set ip 78.47.1xx.xx set port 22 set rootpwd adgajfgjagf set wuser winner set wpwd winner#@! spawn ssh -l $wuse
#!/usr/bin/expect -f
set timeout 2
set ip 78.47.1xx.xx
set port 22
set rootpwd adgajfgjagf
set wuser winner
set wpwd winner#@!
spawn ssh -l $wuser $ip -p $port
expect -re "connecting (yes/no)?" {
send -- "yes\r"
}
expect -nocase -re "password:" {
send "$wpwd\r"
}
expect "# " {
send -- "su - root\r"
expect "Password: "
send -- "$rootpwd\r"
interact
} ## Heading ##
为什么不改用ssh密钥登录呢 对于您希望能够连接的每台机器,您必须请求它们的公共ssh密钥,并将它们添加到自动调整的密钥中。然后,当通过ssh连接时,这些机器不需要输入密码
来源:过去,我不得不处理模糊处理()和文件权限。是的。。我知道我可以做到这一点,但我需要一些其他用途,我没有特权使用ssh密钥。