Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix 连接到其他服务器并获取详细信息_Unix_Ssh - Fatal编程技术网

Unix 连接到其他服务器并获取详细信息

Unix 连接到其他服务器并获取详细信息,unix,ssh,Unix,Ssh,我目前正在处理一个unix问题。我的要求是我在x服务器中,我想通过ssh连接到y服务器,切换到另一个目录并查找一个文件。这里x和y是一些ip地址 我尝试运行此命令: ssh y -l lafter | cd Product | find . -name "hemant" 注意:目前我在x服务器中:上述命令的问题是它显示的是x服务器文件详细信息,而不是y服务器文件详细信息您正在使用管道,而不是在服务器上运行命令y: ssh username@y 'cd Product && fi

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

我尝试运行此命令:

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

注意:目前我在
x
服务器中:上述命令的问题是它显示的是
x
服务器文件详细信息,而不是
y
服务器文件详细信息您正在使用管道,而不是在服务器上运行命令
y

ssh username@y 'cd Product && find . -name "hemant"'
在上面的命令中,我为用户
用户名
(如果未配置密钥,则需要插入
用户名
的密码)打开到服务器
y
的会话

在您的情况下,使用:

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

首先运行
x
命令
find-命名为“hemant”
,然后该命令的输出通过管道传输到命令
cd
stdin
(这里可能会出现错误),最后
cd
的输出通过管道传输到
ssh
stdin
。这个管道序列完全没有用。

您不应该将命令管道连接在一起。而是将参数作为字符串传递给
y

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