'Linux SCP across 2 VMs with PORT and IP Forwarding in sshd_config file of VM1
Aim : Do SCP across 2 VMs with PORT and IP Forwarding in sshd_config file of VM1.
There are 2 servers serverX, serverY.
I would like to transfer a file from my windows machine to remote machine(serverY). But I can't reach serverY directly, hence I am routed via serverX.
Here's how the configuration of serverX portX's /etc/ssh/sshd_config looks
Match user arunch3x
AllowStreamLocalForwarding yes
AllowAgentForwarding yes
AllowTcpForwarding yes
GatewayPorts yes
X11Forwarding yes
PasswordAuthentication yes
AllowTCPForwarding yes
ForceCommand ssh arunch3x@serverY -p portY
When I do ssh to serverX portX, I am automatically routed to serverY portY. SSH is fine. But When I do SCP to serverX portX, its not getting completed, it goes into hang-mode.
Expectation: When I do SCP to serverX portX, it must automatically route to serverY portY as per the configurations and file must land in to serverY portY
Please refer to this SCP command that I am running from Windows machine.
scp -P portX tests.json arunch3x@serverX:/tmp/tests.json
As per the above command file tests.json must land in serverY portY directory /tmp as /tmp/tests/json
Error :
After executing above command it goes into hang mode.
scp -P 30600 tests.json [email protected]:/tmp/tests.json
scp -P 30600 tests.json arunch3x@serverY:/tmp/tests.json
Pseudo-terminal will not be allocated because stdin is not a terminal.
OpenSSH_8.2p1 Ubuntu-4ubuntu0.4, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /home/arunch3x/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname serverY is address
debug2: ssh_connect_direct
debug1: Connecting to serverY [serverY] port portY.
debug1: Connection established.
debug1: identity file /home/arunch3x/.ssh/id_rsa type 0
debug1: identity file /home/arunch3x/.ssh/id_rsa-cert type -1
debug1: identity file /home/arunch3x/.ssh/id_dsa type -1
debug1: identity file /home/arunch3x/.ssh/id_dsa-cert type -1
debug1: identity file /home/arunch3x/.ssh/id_ecdsa type -1
debug1: identity file /home/arunch3x/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/arunch3x/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/arunch3x/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/arunch3x/.ssh/id_ed25519 type -1
debug1: identity file /home/arunch3x/.ssh/id_ed25519-cert type -1
debug1: identity file /home/arunch3x/.ssh/id_ed25519_sk type -1
debug1: identity file /home/arunch3x/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/arunch3x/.ssh/id_xmss type -1
debug1: identity file /home/arunch3x/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.4
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.4 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to serverY:portY as 'arunch3x'
debug3: put_host_port: [serverY]:portY
debug3: hostkeys_foreach: reading file "/home/arunch3x/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/arunch3x/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from [serverY]:portY
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:W6y6gFSbfWwMcRWvyhJVCdwYeEy0NlEMpFtcn2lvitA
debug3: put_host_port: [serverY]:portY
debug3: put_host_port: [serverY]:portY
debug3: hostkeys_foreach: reading file "/home/arunch3x/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/arunch3x/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from [serverY]:portY
debug3: hostkeys_foreach: reading file "/home/arunch3x/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/arunch3x/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from [serverY]:portY
debug1: Host '[serverY]:portY' is known and matches the ECDSA host key.
debug1: Found key in /home/arunch3x/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/arunch3x/.ssh/id_rsa RSA SHA256:0TeS5DDHX3zEccKYK6uMjpwcNPm+gW5l29fzH5rb4cA
debug1: Will attempt key: /home/arunch3x/.ssh/id_dsa
debug1: Will attempt key: /home/arunch3x/.ssh/id_ecdsa
debug1: Will attempt key: /home/arunch3x/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/arunch3x/.ssh/id_ed25519
debug1: Will attempt key: /home/arunch3x/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/arunch3x/.ssh/id_xmss
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected]>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/arunch3x/.ssh/id_rsa RSA SHA256:0TeS5DDHX3zEccKYK6uMjpwcNPm+gW5l29fzH5rb4cA
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: /home/arunch3x/.ssh/id_rsa RSA SHA256:0TeS5DDHX3zEccKYK6uMjpwcNPm+gW5l29fzH5rb4cA
debug3: sign_and_send_pubkey: RSA SHA256:0TeS5DDHX3zEccKYK6uMjpwcNPm+gW5l29fzH5rb4cA
debug3: sign_and_send_pubkey: signing using rsa-sha2-512 SHA256:0TeS5DDHX3zEccKYK6uMjpwcNPm+gW5l29fzH5rb4cA
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).
Authenticated to serverY ([serverY]:portY).
debug3: ssh_init_stdio_forwarding: serverY:portY
debug1: channel_connect_stdio_fwd serverY:portY
debug1: channel 0: new [stdio-forward]
debug2: fd 4 setting O_NONBLOCK
debug2: fd 5 setting O_NONBLOCK
debug1: getpeername failed: Bad file descriptor
debug3: send packet: type 90
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x10
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 80
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug3: receive packet: type 4
debug1: Remote: /home/arunch3x/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug3: receive packet: type 4
debug1: Remote: /home/arunch3x/.ssh/authorized_keys:1: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug3: receive packet: type 91
debug2: channel_input_open_confirmation: channel 0: callback start
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 2097152 rmax 32768
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-104-generic x86_64)
PS C:\Users\arunch3x\OneDrive - Intel Corporation\Documents\tests> debug3: send packet: type 1
debug1: channel 0: free: direct-tcpip: listening port 0 for serverY port portY, connect from 127.0.0.1 port 65535 to UNKNOWN port 65536, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 direct-tcpip: listening port 0 for serverY port portY, connect from 127.0.0.1 port 65535 to UNKNOWN port 65536 (t4 r0 i0/0 o0/0 e[closed]/0 fd 4/5/-1 sock -1 cc -1)
debug1: fd 0 clearing O_NONBLOCK
debug3: fd 1 is not O_NONBLOCK
debug3: fd 2 is not O_NONBLOCK
Killed by signal 1.
Command line just hangs on showing above error.
Can someone please share some inputs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
