发送命令:scp -v -t / 执行请求在通道 0 上失败

发送命令:scp -v -t / 执行请求在通道 0 上失败

尝试使用 scp 命令(或 sftp 或 ssh)将一个简单的 txt 文件(很快将成为 csv 文件)从 Windows Server 2019 发送到远程服务器。远程服务器员工给了我们一个用户名和密码来登录。WinSCP 工作正常。我们的安全团队希望我们不要使用 WinSCP,而是使用 ssh 来自动化它(目前他们正在尝试使用 scp 来找到一种方法)。

初始命令(端口已删除):

scp -v -P ***** Test.txt username@remoteserveraddress:/

这里输出:

C:\Users\username>scp -v -P ***** Test.txt username@remoteserveraddress:/
Executing: program ssh.exe host remoteserveraddress, user username, command scp -v -t /
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Reading configuration data C:\\Users\\username/.ssh/config
debug1: Connecting to remoteserveraddress [remoteserveraddress] port *****.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\username/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\username/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\username/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\username/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\username/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\username/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\username/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\username/.ssh/id_ed25519-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\username/.ssh/id_xmss type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\username/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version Serv-U_15.3.1.155
debug1: no match: Serv-U_15.3.1.155
debug1: Authenticating to remoteserveraddress:***** as 'username'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: ecdh-sha2-nistp256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:superSECRETKEyRedactedForMyProtection:)
debug1: Host '[remoteserveraddress]:*****' is known and matches the RSA host key.
debug1: Found key in C:\\Users\\username/.ssh/known_hosts:1
debug1: rekey after 4******6 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4*******6 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: No such file or directory
username@remoteserveraddress's password:
debug1: Authentication succeeded (password).
Authenticated to remoteserveraddress ([remoteserveraddress]:*****).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending command: scp -v -t /
exec request failed on channel 0
lost connection

答案1

debug1: Remote protocol version 2.0, remote software version Serv-U_15.3.1.155

根据这一行,您显然正在连接到名为Solarwinds 的“Serv-U”

根据这一页Serv-U 不支持 SCP 协议。您需要使用其支持的协议。对于基于 SSH 的文件传输,它显然支持 SFTP。

相关内容