【问题标题】:remote ssh command issue远程 ssh 命令问题
【发布时间】:2016-12-16 21:52:44
【问题描述】:

团队,

我在远程机器上运行命令时遇到了一些困难。我无法理解为什么 ssh 试图认为我传递的命令是主机。

ssh -tt -i /root/.ssh/teamuser.pem teamuser@myserver 'cd ~/bin && ./ssh-out.sh'

|-----------------------------------------------------------------|
| This system is for the use of authorized users only.            |
| Individuals using this computer system without authority, or in |
| excess of their authority, are subject to having all of their   |
| activities on this system monitored and recorded by system      |
| personnel.                                                      |
|                                                                 |
| In the course of monitoring individuals improperly using this   |
| system, or in the course of system maintenance, the activities  |
| of authorized users may also be monitored.                      |
|                                                                 |
| Anyone using this system expressly consents to such monitoring  |
| and is advised that if such monitoring reveals possible         |
| evidence of criminal activity, system personnel may provide the |
| evidence of such monitoring to law enforcement officials.       |
|-----------------------------------------------------------------|

ssh: Could not resolve hostname cd: No address associated with hostname
Connection to myserver closed.

如果我不传递命令,它绝对可以正常工作。它只是让我登录。有什么想法吗?

【问题讨论】:

    标签: ssh remotecommand


    【解决方案1】:

    Man ssh 说:

    如果指定了命令,则在远程主机上执行,而不是 一个登录外壳。

    问题是cd 是内置的 bash(在您的终端中运行 type cd)。因此,ssh 尝试将 cd 作为 shell 运行,但在 PATH 中找不到。

    你应该像这样调用 ssh:

     ssh user@host  -t 'bash -l -c "cd ~/bin && ./ssh-out.sh"'
    

    【讨论】:

      猜你喜欢
      • 2016-10-13
      • 1970-01-01
      • 1970-01-01
      • 2011-05-27
      • 2018-01-31
      • 1970-01-01
      • 1970-01-01
      • 2018-04-21
      • 1970-01-01
      相关资源
      最近更新 更多