Intentar enviar un archivo txt simple (que pronto será un archivo csv) desde Windows Server 2019 usando el comando scp (o sftp o ssh) a un servidor remoto. El empleado del servidor remoto nos dio un nombre de usuario y contraseña para iniciar sesión. WinSCP funciona bien. A nuestro equipo de seguridad le gustaría que no usáramos WinSCP, sino que lo automaticáramos usando ssh (que actualmente están tratando de encontrar una manera con scp).
Comando inicial (puerto redactado):
scp -v -P ***** Test.txt username@remoteserveraddress:/
Salida aquí:
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
Respuesta1
debug1: Remote protocol version 2.0, remote software version Serv-U_15.3.1.155
Según esta línea, aparentemente te estás conectando a un producto de servidor llamado"Serv-U" de Solarwinds.
De acuerdo aesta página, Serv-U no es compatible con el protocolo SCP. Necesitará acceder al servidor usando uno de susprotocolos soportados. Para transferencias de archivos basadas en SSH, aparentemente es compatible con SFTP.