我试图阻止远程调用脚本。用户需要先登录SSH,然后运行脚本
ssh remote-server "script.sh"应该失败
ssh remote-server和登录后的./script.sh应该可以工作
我可以更改所有权并应用chmod,但是远程用户可以使用ssh remote-server "sudo -u newuser ./script.sh"。
使用AWS EC2实例
发布于 2017-07-07 10:50:27
运行ssh foo@remote-server和./script.sh等价于运行ssh foo@remote-server ./script.sh,运行ssh foo@remote-server和sudo -u bar ./script.sh等价于ssh foo@remote-server sudo -u bar ./script.sh (除了sudo可能会失败,因为它需要一个TTY,可以轻松地工作)。所以恐怕你的要求是不合理的。您为解决这种人为差异所做的任何事情,例如测试是否存在$TERM或[ -t 0 ],都可能很容易解决。
https://unix.stackexchange.com/questions/375946
复制相似问题