【问题标题】:execute local script on remote host as root, doesn't let you enter password以root身份在远程主机上执行本地脚本,不允许您输入密码
【发布时间】:2014-03-23 08:08:00
【问题描述】:

我正在尝试以 root 身份在远程 AIX 服务器上运行本地脚本,但它并没有暂停让我输入 sudo 密码。

ssh -t user@host 'sudo su' < action.sh
user@host's password:
Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
Sorry, try again.
sudo: 3 incorrect password attempts

不传入脚本就可以正常执行。

$ ssh -t user@host 'sudo su'
user@host's password:
Password:
# whoami
root
#

action.sh 只包含一个用于测试的“ls -al”命令。

我怎样才能让这个暂停,以便我可以输入我的密码?

【问题讨论】:

    标签: ssh sh sudo aix


    【解决方案1】:

    这种行为很简单:

    STDIN 由您的脚本提供,因此每一行都作为输入文件中的密码传递。

    解决方案是使用一对ssh 键。 Here is a how to to do it.

    【讨论】:

      猜你喜欢
      • 2020-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-27
      • 1970-01-01
      • 1970-01-01
      • 2019-05-19
      • 2011-05-09
      相关资源
      最近更新 更多