【发布时间】:2020-10-12 17:21:43
【问题描述】:
我正在尝试编写一个本地 Bash 脚本以自动(设置为由 cron 运行)通过 SSH 执行多个远程任务,包括一些需要 sudo 的任务。我希望从文件中读取密码,然后通过 ssh 登录,然后使用任何远程 sudo 命令。我还想确保密码不是通过网络以明文形式或在远程计算机的历史记录中发送的。
(类似下面的东西不起作用)
#! /bin/bash
sshpass -f mypasswordfile ssh -tt remoteid@remotesever << EOF
$hostname # remote server name
sudo apt update
sudo apt upgrade -y
whoami
# etc.. etc.. assortment of health, security and other maintenance tasks
EOF
【问题讨论】: