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

时间:2016-10-18 22:27:50

标签: linux ssh scp

我尝试使用scp(安全副本)将文件夹从一个系统复制到另一个系统但是我无法确定如何指定端口。

我明白scp,我可以......

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

但是我已经更改了目标系统的SSH端口,因此我收到此错误...

  

ssh:连接到主机 。*。***端口22:连接拒绝丢失   连接

是否有某种-p命令可用于指定端口号?

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

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

更新了解决方案......

我不仅在使用错误的-P而且还在哪里放置。我知道理解,这对我有用......

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

1 个答案:

答案 0 :(得分:3)

使用大写-P port。小写-p选项与-p中的cp“保留”选项冲突。

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.