3

I am logged in to a remote host and trying to push a file back to my local machine.

Using scp myusername@university_computer:/home/myusername/filename /home/myname/folder results in the error message: /home/folder: No such file or directory. When I "am" the remote machine it can't see the local machine.

So how do I identify the local machine so it is recognized?

The two relevant questions on this topic don't address this problem.

2 Answers 2

2

Not entirely sure if this answers your question properly, but when using scp to copy files over the internet, I believe you have to use a resolvable hostname or IP in place of the machine hostname. For example, if you wanted to copy a file (from the current active directory in the console on the remote machine you are logged into) to your home machine (assuming the hostname of the home machine is home_comp and the ip is [non-valid placeholder ip] 257.344.104.36) you would do scp /home/userx/foo usery@257.344.104.36:~/bar.

This would copy "/home/userx/foo" on the machine currently logged into, to "bar" in the home directory of "usery" on the machine at 257.344.104.36, provided you have the correct login credentials and the machine at 257.344.104.36 accepts connections on the correct port (port 22 by default, if I remember correctly).

3
  • If there is a search line in /etc/resolv.conf the domain part of the FQDN part can be determined automatically. Also, an entry in the .ssh/config could turn a single name into a resolvable host/IP Sep 8, 2015 at 0:22
  • OK, I've found 'usery' with hostname and my IP with ifconfig. The remote now tries to connect to the local machine, asking for a password. But it returns Permission denied, please try again. when I enter the local machine's password (or the remote's).
    – Friasco
    Sep 9, 2015 at 10:49
  • Hm. Sounds to me like the machine you're trying to copy to is refusing the authentication, but not because the password is wrong... Does 'usery' have permission to write to the directory you are trying to copy the file into?
    – re-cursion
    Sep 9, 2015 at 23:01
1

Many machines don't have direct access to the Internet. They're behind a network appliance that performs network address translation (NAT): the machine has an IP address that's only valid on the internal network. When the machine makes a connection to an outside server, the NAT appliance relays the connection, so that the server sees a connection coming from the NAT appliance.

This makes it impossible to make incoming connections to the internal machine, since connections from the outside can only reach the NAT appliance. Unless the NAT appliance has been configured to relay incoming connections, which is rarely the case (which of the many internal machines would it relay each connection to?), incoming connections are not possible.

If your local machine is behind a NAT, you can only make outgoing connections. If you want to copy a file, open another terminal locally, and run scp, sftp or sshfs to transfer files. To speed up the establishment of subsequent connections, you can configure SSH to piggyback on the existing secure channel.

If you need that often, you can build a reverse SSH tunnel. It's a trade-off: longer setup, but a convenience gain once it's in set up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.