2

I know there are already some threads about this, but none of them helped me to solve my problem. I want to send a simple text file from my Linux machine to my windows 10 PC using the scp command. So this is what I type in my Linux console:

scp -P80  test.txt mywindowsusername@mywindowsip:/Desktop

I use port 80 because otherwise the system tells me port 22 is closed.

After a while I get the error:

ssh_exchange_identification: Connection closed by remote host 

lost connection

I also tried a lot of different commands like copying the file to a different folder and using

-r

after the port but the error is always the same.

Does somebody has an idea how to fix this?

2
  • 3
    Do you have an ssh or scp server running on windows? Regardless, this has nothing to do with security. Jan 16, 2019 at 22:41
  • It's true this question belongs on SuperUser or Linux/Unix but that said: sounds like firewall rules. Check both computers that they will allow send/recieve on port 22 and try again. Make sure there is an SSH server set up on the Windows machine (there are tutorials online). You can also use the graphical based WinSCP which always worked for me.
    – bashCypher
    Jan 16, 2019 at 22:54

3 Answers 3

0

You have said that the system would tell you that port 22 is closed. But obviously, your system does not tell you that port 80 is closed. That would mean that on the Windows PC you have running a piece of software which listens on port 80, but not on port 22 (this could be a web server then), or that the firewall on the Windows PC is configured to let pass through inbound traffic on port 80, but not on port 22.

An "scp server" is usually incorporated into an SSH server (at least, I never have heard of somebody actually using a standalone SCP-only server). This means that you probably have to install an SSH server on your Windows PC. Please note that Windows does not incorporate such a server (perhaps unless you are using Microsoft's Unix subsystem which they ship with the new Windows versions, but I don't know).

When having installed the SSH server on your Windows PC, please be aware that it will listen on port 22 by default. If you want it to listen on port 80, you will have to change its configuration. The exact configuration method and steps depend on the server software, of course.

If I were you, I would do the following:

1) Check out why port 80 is open on your Windows machine (check for installed software which might run unintentionally, check the firewall settings). If port 80 is open by accident, close it.

2) Install the SSH server on your Windows machine.

3) Configure the firewall on your Windows machine to let in TCP connections on port 22, possibly restricted to certain hosts (your Linux machine), and possibly allowed to certain programs only (the SSH server).

It should work then.

0

To copy a file from Linux to Windows, execute the following command from Windows (no Windows SSH server required):

scp user@ip:/dir1/dir2/file "D:\dir1\dir2"
0

From your windows machine, SSH into the linux machine you want to get the file from then scp from your ssh client. It comes through some binary channel over your SSH connection.

You could also consider running a small FTP server on windows.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .