SCP File Transfer – How to Fix Hanging Issues

file-sharingfile-transferscp

I am trying to move a file from a virtual machine (Ubuntu 18.04) on my local system to a remote server using a very basic scp command. This issue is present only on one particular server, others work fine so it is not a generic thing.

scp <file name> <user>@<complete_hostname>:~/

But this command does not proceed beyond authentication which is successful.

SCP Log: (from local machine, Ubuntu 18.04)
==========
debug1: Next authentication method: publickey
debug1: Offering public key: 
RSA SHA256:<key> /home/username/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279 
debug1: Authentication succeeded (publickey).
Authenticated to 'HOSTNAME' ([10.6.26.145]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LANG = en_IN
debug1: Sending command: scp -v -r -d -t ~/received/


Form another  remote server:
debug1: Next authentication method: publickey
debug1: Trying private key: /home/username/.ssh/identity
debug1: Offering public key: /home/username/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/username/.ssh/id_dsa
debug1: Trying private key: /home/username/.ssh/id_ecdsa
debug1: Next authentication method: password
username@hostname's password: 
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = C
debug1: Sending env LC_ALL = C
debug1: Sending command: scp -v -t ~/

I do not have any privileged access on these machines , is there a way to find out what is going wrong? What would I need to do the same?

Best Answer

For future readers,

# This will use port 2222
scp -v -P 2222 ~/local_file.txt admin@remote:~/dest

but

# This will use default port 22 and ignore your 2222
scp -v ~/local_file.txt -P 2222 admin@remote:~/dest

so scp could seem to hang this way (wrong port). The -v flag is your friend.