18

I am running a script on a remote machine and I would like to copy the output file on my pc, using scp.

I am perfectly able to copy files from my pc to the remote one, but apparently I am not in doing the opposite:

I have tried with both my hostname and ip adress, with :

scp star_101out.txt alessandra@ip_adress:/home/alessandra/Dropbox/tesi\ alle/Python

and I get this error:

                Connection timed out

                  lost connection

what should I do?

Argentina
  • 1,071
  • 5
  • 16
  • 30
  • Are you sure you have an SSH daemon running on your machine? If not, you have to initiate the copy from your local PC, using a different terminal: `scp remote:/path/to/file path/to/local/file`. – SukkoPera Oct 14 '14 at 15:19
  • I am not sure, if I type what you suggested I get : ssh: Could not resolve hostname remote: Name or service not known – Argentina Oct 14 '14 at 15:23
  • Well, you are supposed to replace *remote* and the rest with the actual hostname of the machine you are connecting to :). The same one you use when you do *ssh*. – SukkoPera Oct 14 '14 at 15:25
  • ok! It worked!thank you, but I still don't understand how to copy from remote to my pc, the opposite path – Argentina Oct 14 '14 at 15:37
  • You are actually copying from remote do your PC, you are just "pulling" the file. If you want to "push" it, initiating the copy from the remote server, you need to make your PC reachable from the remote one via SSH. It's basically the same thing as you are doing when you connect to the remote server, just with roles inverted. Anyway I would suggest to connect via SFTP with a graphical client, such as Filezilla, which will allow you to exchange files freely in both directions. – SukkoPera Oct 14 '14 at 15:44
  • 1
    AlessandraFerri - In addition to SukkoPera's comment, firewall may prevent the connection from the server to your pc. If initiating the connection from your pc to the server works, you can do both pull and push as @SukkoPera already said. – alvits Oct 14 '14 at 18:22
  • if you're in aws and you setup ssh to your ip and then you connect to your corporate vpn, and then try to ssh, your connection will time out ;) – Datum Geek May 11 '20 at 16:40
  • Make sure you are not having a concurrent connection open. Sometimes default configuration prohibits that. – Kinformationist Nov 07 '21 at 07:18

4 Answers4

17

After spending way too long on this, scp reports this error any time the syntax of the command line is wrong. If ssh works to the host that you are trying to reach, but scp returns this error, the scp command line is not understandable by scp - ie despite the error message, the error is not Connection related.

The mistake may be an invisible character. This can happen if you try to paste a long file name using ^v for example, but the character is entered into the command line instead.

Retype your request and insure that you don't insert invisible characters.

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
Kelly MacInnis
  • 239
  • 2
  • 7
  • 1
    I found out that the scp required to type the full filename on the target side, i.e. just typing "scp file.txt user@ip:/somewhere/" with a trailing slash didn't work. Typing out the full thing worked `scp file.txt user@ip:/somewhere/file.txt` - seems a bit out of the normal – Jonny Jul 28 '20 at 10:11
  • for me the issue was specifying port with small `-p` but rather `-P` – Basheer Kharoti Sep 15 '21 at 09:25
5

Check the firewall of the servers . and also check if server is reachable, check if sshserver is running

sumanta
  • 359
  • 3
  • 7
0

I had the same timeout issue when trying to download images via sftp, and after a lot of config changes and things that did not work for me, I've found out that the default wlan0 adapter that is on the raspberry pi is at fault. So I've added in the usb slot an external Wifi adapter, connected it to my network and never had the timeout issue ever again. Also in order to make sure that the connection would not jump back to the board wifi adapter I've disabled it from terminal using the command:

sudo iwconfig wlan0 txpower off

and if you want to turn it back on you

sudo iwconfig wlan0 txpower off

MSA
  • 2,502
  • 2
  • 22
  • 35
-1

My problem was that Zone Alarm was randomly cutting my connections from my Ubuntu subsystem for Windows. You could try to disable your local firewall. My Putty SSH connections where running well too.