scp "lost connection" but ssh works fine

scp works by making an ssh connection to the remote host, then launching another copy of the scp program on that host. The two scp instances communicate through the ssh connection to perform the file transfer.

"lost connection" is printed by the local scp program when the ssh connection drops prematurely. The usual reason for that is the scp program on the remote host either failed to start or else it exited prematurely. This could have happened because the scp program doesn't exist on the remote host, or it's not in your command PATH, or it's not marked executable, or it crashed after starting, or something along those lines.


Had the same issue.

If you did a minimal install of Centos, it only install the openssh and openssh-server packages but not the openssh-clients. sudo yum install openssh-clients will fix your issue.

Tags:

Ssh

Scp