Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I copy files from my local to some remote server which hosts ssh on port other than default (22).

I usually connect to the server using

ssh -p 2000

Now I need to copy files with scp

user@localbox:~$ scp ~/.ssh/ user@remotebox.remotedomain.tld:~/.ssh/ -p 2000

But this does not work.

share|improve this question
sshfs is also an option :) – user323419 Feb 3 at 0:05
up vote 22 down vote accepted

scp --help or man scp would have told you the option was -P port. You also need to declare this before the file arguments:

scp -P 2000 -i ~/.ssh/ user@remotebox.remotedomain.tld:~/.ssh/

I also wouldn't trust ~-relative links. Use full paths if you can.

But if you're copying IDs, ssh-copy-id also has an option to provide SSH connection options:

ssh-copy-id -i ~/.ssh/ '-p 2000 user@remotebox.remotedomain.tld'
share|improve this answer
// , Is there a way to search through the man pages for stuff like this? – Nathan Basanese Aug 26 '15 at 0:00

use a capital P

(it's in the man page...)

share|improve this answer

You can create file ~/.ssh/config and put relevant information for the remote host in there:

Port 2000
User username

See man page for ssh_config.

This allows you to then run ssh as:


and scp as:

scp important_file
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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