sudo - sorry you must have a tty to run sudo 解决方法
问题说明
刚刚配置了SUDOWS来执行SSH连接中没有密码的命令,报错:
sudo: sorry, you must have a tty to run sudo
解决方式
修改 sudoers 配置
替换 /etc/sudoers
中 Defaults requiretty
by Defaults !requiretty
。该修改影响全局配置。
你也可以为单独用户、用户组或指定命令设置权限限制:
Defaults!/path/to/my/bin !requiretty
Defaults:myuser !requiretty
ssh -t 访问
ssh 链接时,使用 -t
参数:
ssh -t root@10.10.10.10
From man ssh: text -t Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.
未测试:
export HASTTY=1