Question
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.
Answer
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'