7

I can successfully connect to my server via ssh but when trying to run the scp command I get a connection time out.

$ scp ~/.ssh/id_rsa.pub root@192.168.12.2:id_rsa.pub
ssh: connect to host 192.168.12.2 port 22: Connection timed out
lost connection

Yes I do have openssh-client and openssh-server installed on both my machines the client and the server.

My router is also configured to forward ssh port 22 and no I don't have a firewall enabled.

closed as off-topic by chaos, John WH Smith, jimmij, Michael Homer, jasonwryan Mar 25 '15 at 21:01

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – chaos, John WH Smith, jimmij, Michael Homer, jasonwryan
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    That's very weird. Because scp works by running ssh. While its sitting there (before the timeout) you should be able to catch the ssh command via ps x | grep scp or similar. Does that command work if you run it directly, minus the scp -t . at the end? – derobert Jul 3 '14 at 19:25
  • 1
    I'm confused by your comment that it works on the server side but not the client side? I thought we were only trying from one side??? Does ssh (client) work from the side you're running scp on? – derobert Jul 3 '14 at 20:14
  • 2
    1. try scp -i with a path to your keys 2. try -v to get more info on the time out – denten Jul 3 '14 at 20:15
  • 1
    I go it working again, but with a different authentication key, the previous one had a password for encryption reasons and then well I took it off. – user3802988 Jul 3 '14 at 21:36
  • 1
    Is this solved? It is a bit hard to tell from your last comment. I think that derobert's suggestion is a good one. From the ssh_config man page: ClearAllForwardings - Specifies that all local, remote, and dynamic port forwardings specified in the configuration files or on the command line be cleared. This option is primarily useful when used from the ssh command line to clear port forwardings set in configuration files and is automatically set by scp(1) and sftp(1). The argument must be yes or no. The default is no. – Warwick Jul 4 '14 at 0:36
0

I am a little confused by your command because I don't understand where you are trying to drop the file but if you fix this, it should work:

This is wrong:

scp ~/.ssh/id_rsa.pub root@192.168.12.2**:id_rsa.pub**

The above line does not have the correct path. It should look like this:

scp ~/.ssh/id_rsa.pub root@192.168.12.2:/root(or other user path)/.ssh/id_rsa.pub

Basically what you are missing is the ' / ' after the ' : ' and the correct path location to where you want to drop the file. Also as a side-note, you just need the path, the name of the file at the end of that path works more like a renaming feature. So using the above example again, this too is also valid:

scp ~/.ssh/id_rsa.pub root@192.168.12.2:/root(or other user path)/.ssh/
0

Make sure you aren't using the wrong port. To specify a port, pass the -P option. See also https://askubuntu.com/a/182482

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