linux - 通过 ssh scp 到另一个不使用端口 22 的 Linux 系统

标签 linux ssh scp

我正在尝试使用 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/

相关文章:

linux - GitLab SSH 请求密码并忽略 SSH key

linux - TIZEN SDB Shell - 输入点击或触摸屏命令

java - SSH 使用 jschexception verify false 有时会失败

linux - 命令不会在脚本中运行

ssh - 尽管ssh可以正常工作,但scp给出了超时错误

c++ - 在 x11 系统上使用 opengl 和 GL/gl.h 和 GL/glx.h 绘制三角形

linux - Jenkins 没有标签 Linux

amazon-web-services - 无法使用 ssh 从 Windows 10 CMD 连接到 EC2 Linux 实例

scp - 如何在 scp URL 中输入带有特殊字符的密码

java - mtime.sec 不存在