通过 ssh scp 到另一个 linux 系统,其中不使用端口 22

scp to another linux system via ssh where not using port 22

我正在尝试使用 scp(安全复制)将文件夹从一个系统复制到另一个系统,但是我不知道如何指定端口。

我理解到scp,我可以...

scp /file/location/folderName user@192.***.*.***:/destination/location/

但是我已经更改了目标系统的 SSH 端口所以我得到了这个错误...

ssh: connect to host ..*.*** port 22: Connection refused lost connection

我可以使用某种 -p 命令来指定端口号吗?

我也试过这样添加端口...

scp /file/location/folderName user@192.***.*.***:>>portNumHere<</destination/location/

已更新解决方案...

我不仅纠结于使用错误的 -P,而且纠结于放在哪里。我知道明白,这对我有用...

scp -r -P >>portNumHere<< /file/location/folderName user@192.***.*.***:/destination/location/

使用大写-P port。小写 -p 选项与 cp.

中的 -p "preserve" 选项冲突

根据 the man page:

 scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
     [-l limit] [-o ssh_option] [-P port] [-S program]
     [[user@]host1:]file1 ... [[user@]host2:]file2

 ...

 -P port
         Specifies the port to connect to on the remote host.  Note that
         this option is written with a capital ‘P’, because -p is
         already reserved for preserving the times and modes of the
         file.