嘗試使用 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。