我在AWS的EC2实例上使用sshpass:
[ec2-user@ip-xx-xx-xx-xx ~]$ sshpass
Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
-f filename Take password to use from file
-d number Use number as file descriptor for getting password
-p password Provide password as argument (security unwise)
-e Password is passed as env-var "SSHPASS"
With no parameters - password will be taken from stdin
-h Show help (this screen)
-V Print version information
At most one of -f, -d, -p or -e should be used
这有效,现在我创建了一个使用它的脚本,它可以正常工作。
现在,我需要让cron
让脚本运行。
我尝试过sudo crontab -u ec2-user -e
,还尝试过更新/etc/crontab
并在那里指定ec2-user,但是脚本每次都会失败。
我看到的错误是:
/script.sh: line 3: sshpass: command not found
当我尝试这样做时:
sudo -u ec2-user "sshpass"
我明白了
sudo: sshpass: command not found
我不想为sudo / root用户安装sshpass。我该如何工作?