我正在尝试使用 scp(安全复制)将文件夹从一个系统复制到另一个系统,但是我无法弄清楚如何指定端口。
我明白,对于scp,我可以...
scp /file/location/folderName user@192.***.*.***:/destination/location/
Run Code Online (Sandbox Code Playgroud)
但是我更改了目标系统的 SSH 端口,因此出现此错误...
ssh:连接到主机。.*.*** 端口 22:连接被拒绝丢失连接
我可以使用某种 -p 命令来指定端口号吗?
我也尝试像这样添加端口......
scp /file/location/folderName user@192.***.*.***:>>portNumHere<</destination/location/
Run Code Online (Sandbox Code Playgroud)
更新了解决方案...
我不仅在使用错误的 -P 上遇到困难,而且在放置位置上也遇到困难。我知道理解这对我有用......
scp -r -P >>portNumHere<< /file/location/folderName user@192.***.*.***:/destination/location/
Run Code Online (Sandbox Code Playgroud)
使用大写-P port
。小写选项与中的“preserve”选项-p
冲突。-p
cp
根据手册页:
\n\n scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]\n [-l limit] [-o ssh_option] [-P port] [-S program]\n [[user@]host1:]file1 ... [[user@]host2:]file2\n\n ...\n\n -P port\n Specifies the port to connect to on the remote host. Note that\n this option is written with a capital \xe2\x80\x98P\xe2\x80\x99, because -p is\n already reserved for preserving the times and modes of the\n file.\n
Run Code Online (Sandbox Code Playgroud)\n