scp:非法选项 - 0

scp:非法选项 - 0

我正在尝试通过 shh 连接将数据复制到远程服务器。

我收到以下错误:

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

我使用的脚本执行此请求:

 scp -p10012 /Users/trst/Docs/repositories/pro/.envoydeploy/tmp/servers/172.12.11.150 [email protected]:/var/www/pro/tmp/service_owner

答案1

scp中设置端口的开关是大写的-P

 -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 in
         rcp(1).

 -p      Preserves modification times, access times, and modes from the
         original file.

小写字母-p不带参数,因此10012被视为进一步的选项序列; options-1-2是有效选项(控制 SSH 协议),但-0不是 - 因此会出现错误。

相关内容