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'

本文解答了如何通过SCP命令指定非默认SSH端口进行文件传输的问题,并提供了正确的SCP命令用法示例。
3090

被折叠的 条评论
为什么被折叠?



