linux – 通过SSH以sudo身份运行多个命令

前端之家收集整理的这篇文章主要介绍了linux – 通过SSH以sudo身份运行多个命令前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_404_1@我试图通过SSH运行sudo命令,但没有成功:
ssh -t -p 2222 name@server /usr/bin/sudo << EOF
  chmod u-r /xy 
  chmod +x /xy
  /xy
  sleep 5
  ps aux | grep xy
  sleep 5
  exit
EOF

这不起作用.没有-t和/usr/bin/sudo:

sudo: no tty present and no askpass program specified

单行命令正在运行:

ssh -p 13001 -t name@server 'sudo /xy'

解决方法

这应该工作:
ssh -t -p 2222 name@server "/usr/bin/sudo bash -c 'chmod u-r /xy; chmod +x /xy; ...'"
原文链接:https://www.f2er.com/linux/395900.html

猜你在找的Linux相关文章