我目前正在寻找一种解决方案,用于从包含“user:password”的输入文件中执行多个本地服务器上的远程命令,格式如下:
jboss5:manager:192.168.1.101
database1:db01:192.168.20.6
server8:localnet:192.168.31.83
x:z:192.168.1.151
test:mynet:192.168.35.44
.... and others我希望远程执行一些命令:
cd $HOME; ./start_script.sh; wget 192.168.1.110/monitor.sh; chmod +x monitor.sh; ./monitor.sh我知道有一个叫做"sshpass“的实用程序,但我不确定如何将这个实用程序应用于我的需要。
发布于 2018-10-02 11:45:51
Yes sshpass is a good option, you can use it as below
sshpass -p "pass_here" ssh user@ip "cd $HOME; exit" #password is provided on the command line with semi-colon separated commands
Note: you need to install sshpass before you use it, it can be install using simple command as below,
apt-get install sshpasshttps://unix.stackexchange.com/questions/466114
复制相似问题