我正在尝试使用 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端口
。小写的 -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.
关于linux - 通过 ssh scp 到另一个不使用端口 22 的 Linux 系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40119115/