在 sudoers 中分别设置环境变量 SSH_ASKPASS 或 askpass [英] set environment variable SSH_ASKPASS or askpass in sudoers, resp

查看:44
本文介绍了在 sudoers 中分别设置环境变量 SSH_ASKPASS 或 askpass的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试登录 ssh 服务器并执行以下操作:

I'm trying to login to a ssh server and to execute something like:

ssh user@domain.com 'sudo echo "foobar"'

很遗憾,我遇到了一个错误:

Unfortunately I'm getting an error:

sudo: no tty present and no askpass program specified

Google 告诉我设置环境变量 SSH_ASKPASS 或在 sudoers 文件中设置 askpass.我的远程机器在 Debian 6 上运行,我已经安装了包 ssh-askpassssh-askpass-gnome 并且我的 sudoers 文件看起来像这样:

Google told me to either set the environment variable SSH_ASKPASS or to set askpass in the sudoers file. My remote machine is running on Debian 6 and I've installed the packages ssh-askpass and ssh-askpass-gnome and my sudoers file looks like this:

Defaults        env_reset
Defaults        askpass=/usr/bin/ssh-askpass

# User privilege specification
root    ALL=(ALL) ALL
user    ALL=(ALL) ALL

谁能告诉我我做错了什么以及如何做得更好.

Can someone tell what I'm doing wrong and how to do it better.

推荐答案

有两种方法可以摆脱这个错误信息.简单的方法是为远程 sudo 进程提供一个伪终端.您可以使用选项 -t 来做到这一点:

There are two ways to get rid of this error message. The easy way is to provide a pseudo terminal for the remote sudo process. You can do this with the option -t:

ssh -t user@domain.com 'sudo echo "foobar"'

这篇关于在 sudoers 中分别设置环境变量 SSH_ASKPASS 或 askpass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆