Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 username@remotehost.com -p 2000

Now I need to copy files with scp

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

But this does not work.

share|improve this question

2 Answers 2

up vote 14 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 ~/.ssh/id_rsa.pub user@remotebox.remotedomain.tld:~/.ssh/id_rsa_localbox.pub

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/id_rsa.pub '-p 2000 user@remotebox.remotedomain.tld'
share|improve this answer

use a capital P

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

share|improve this answer

Your Answer

 
discard

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.