该系统找不到指定的路径

该系统找不到指定的路径

我的情况如下。我有一个 Windows 服务器和一个 Linux 服务器。在我的 Windows 服务器上,我安装了 Sharepoint,能够通过执行命令通过 Windows 命令行访问共享目录dir,并且能够将共享目录映射到本地的网络驱动器。

dir "\\XX.XX.XX.XX\DavWWWRoot\Shared Documents\AllDocuments\ImpDocuments"

当我尝试通过 ssh 从 Linux 机器访问该内容时,出现了问题。

ssh -v [email protected] cmd /c dir "\\\\XX.XX.XX.XX\\DavWWWRoot\\Shared Documents\\AllDocuments\\ImpDocuments"

错误:Access Denied.

请提供想法!

OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
debug1: Reading configuration data /etc/ssh/ssh_config`
debug1: Applying options for *
debug1: Connecting to XX.XX.XX.XX [XX.XX.XX.XX] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version VShell_4_0_1_478 VShell
debug1: no match: VShell_4_0_1_478 VShell
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'XX.XX.XX.XX' is known and matches the DSA host key.
debug1: Found key in /root/.ssh/known_hosts:10
debug1: ssh_dss_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
Cannot determine realm for numeric host address

debug1: Unspecified GSS failure.  Minor code may provide more information
Cannot determine realm for numeric host address

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information
Cannot determine realm for numeric host address

debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Offering public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,gssapi-with-mic
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Next authentication method: password
[email protected]'s password:
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending command: cmd /c dir \\\\XX>XX.XX.XX\\DavWWWRoot\\Shared Documents\\AllDocuments\\ImpDocuments
Access is denied.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 1824, received 1920 bytes, in 17.4 seconds
Bytes per second: sent 104.8, received 110.3
debug1: Exit status 1

答案1

您需要将反斜杠加倍,因为它们会被 shell 解释:

ssh [email protected] cmd /c dir "\\\\XX.XX.XX.XX\\DavWWWRoot\\Shared Documents\\AllDocuments\\ImpDocuments"

答案2

在访问目标文件系统之前,您需要在 Linux 系统上安装它。

mount -t cifs -o username=user1,password=abc123 //XX.XX.XX.XX/share /mnt/share

然后您可以使用 ls 或其他实用程序来查看和/或编辑文件。

ls /mnt/share/file

假设它有效,您可以将挂载添加到 Linux 系统的 /etc/fstab 文件中,以便在启动时自动挂载。

答案3

这可能是您运行的命令中的拼写错误吗?

debug1: Sending command: cmd /c dir \\\\XX>XX.XX.XX\\DavWWWRoot\\Shared...
                                          ^

如果不行,我会尝试引用 windows 命令,以便 ssh 将其视为单个字符串。您可能需要反复使用或不使用反斜杠:

ssh -v [email protected] 'cmd /c dir "\\\\XX.XX.XX.XX\\[etc]\\ImpDocuments"'

如果这仍然不起作用,请尝试与 Windows 服务器建立交互式 SSH 连接,然后尝试dir在该会话中运行该命令。Windows SSH 服务器可能未正确设置您的会话,并且您以这种方式进入时无法访问网络。

相关内容