【问题标题】:How to use scp URI with different port?如何使用具有不同端口的 scp URI?
【发布时间】:2012-12-20 21:56:59
【问题描述】:

我想使用scp 自动复制。如果我使用默认的 ssh 端口,URI 将如下所示:

scp://root@host:/root/ids/rules.tar.gz

但我将 ssh 端口更改为 3131。如何获取 ssh 端口并将其附加到 scp 命令?

【问题讨论】:

标签: ssh scp


【解决方案1】:

从 7.7 版开始,常用的scp 命令行实用程序接受 URL 作为命令行参数。在 URL 中指定端口号的常用方法是跟随主机名:

scp://root@host:3131/root/ids/rules.tar.gz
                ^^^^

或者,scp 有一个 -P 选项来指定端口:

scp -P 3131 root@host:/root/ids/rules.tar.gz .

【讨论】:

  • 值得注意的是,"scp://root@host:/..." 应该在 'host:' 后面有一个端口 "number",并且由于缺少它,它使用默认端口 22对于 ssh。如果没有端口号,“:”对于绝对路径也可以省略(即'...@host/path...'),但在不以'/'开头的路径上是必需的(即'...@host:subdir/morepath...')
【解决方案2】:

你可以在命令中使用 scp -P

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-14
    • 1970-01-01
    • 1970-01-01
    • 2012-05-07
    • 1970-01-01
    • 2013-12-13
    • 2011-08-29
    • 2017-11-28
    相关资源
    最近更新 更多