【问题标题】:ssh config name alias not working for scp [closed]ssh 配置名称别名不适用于 scp [关闭]
【发布时间】:2013-09-07 10:10:33
【问题描述】:

使用 scp 时出现此错误:

scp -r h1:/dir1 h2:/dir1
ssh: Could not resolve hostname online1: Name or service not known
lost connection

但是ssh h1ssh h2 都很好用,因为我在 .ssh/config 中有这样的配置名称别名:

Host h1
  HostName 172.16.18.xxx
  User xxx

在 /etc/hosts 上没有编辑。我还使用ssh-copy-id 来计算公钥。知道出了什么问题吗?

【问题讨论】:

    标签: linux ssh scp


    【解决方案1】:

    当您在此处使用 scp 而没有像您这样的其他选项时,远程 h1 会尝试直接连接到 h2。

    h1 -> h2
    

    由于h1需要知道h2是谁,h1需要h2的定义。但您也可以通过您的 PC 路由它,例如

    h1 -> your pc -> h2
    

    使用选项-3

    scp -r -3 h1:/dir1 h2:/dir2
    

    【讨论】:

    • 应该是“路线”吗?
    【解决方案2】:

    当 'myserver' 在 ssh 配置文件中用作别名时,这会有所帮助

    sudo scp -F ~/.ssh/config -i ~/.ssh/id_rsa some_local_file.zip myserver:some_remote_folder/
    

    【讨论】:

      猜你喜欢
      • 2012-04-29
      • 2013-03-24
      • 1970-01-01
      • 2020-08-13
      • 2015-07-01
      • 2012-12-01
      • 1970-01-01
      • 2015-10-24
      • 1970-01-01
      相关资源
      最近更新 更多