【问题标题】:connecting to another server and getting details连接到另一台服务器并获取详细信息
【发布时间】:2017-10-31 22:23:57
【问题描述】:

我目前正在处理一个 unix 问题,我的要求是我在 x 服务器上我想通过 ssh 连接到 y 服务器,切换到另一个目录并找到一个文件。这里xy是一些ip地址。

我试图运行这个命令:

ssh y -l lafter | cd Product | find . -name "hemant"

注意目前我在x 服务器:上面命令的问题是它显示x 服务器文件详细信息而不是y 服务器文件详细信息

【问题讨论】:

    标签: unix ssh


    【解决方案1】:

    您不应该将这些命令放在一起。而是将参数作为字符串传递给y

    ssh y -l lafter 'cd Product && find . -name "hemant"'
    

    【讨论】:

      【解决方案2】:

      您正在使用管道而不是在服务器上运行命令y

      ssh username@y 'cd Product && find . -name "hemant"'
      

      在上面的命令中,我为用户 username 打开一个到服务器 y 的会话(如果没有配置密钥,您需要插入 username 的密码)

      在你的情况下,使用:

      ssh y -l lafter | cd Product | find . -name "hemant"
      

      你首先在x 上运行命令find . -name "hemant",然后这个命令的输出通过管道传送到命令cdstdin(这里你可能会得到一个错误),最后是输出cd 通过管道传输到 sshstdin。这种管道序列完全没用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-03-04
        • 2017-07-16
        • 2012-08-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多