linux - ssh 配置名称别名不适用于 scp

标签 linux ssh scp

<分区>

我在使用 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 来计算公钥。知道哪里出了问题吗?

最佳答案

当您使用 scp 而没有其他选项时,远程 h1 会尝试直接连接到 h2。

h1 -> h2

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

h1 -> your pc -> h2

使用选项-3

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

关于linux - ssh 配置名称别名不适用于 scp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18604750/

相关文章:

linux - 当我将 `&` 与 Bash 脚本中的函数一起使用时会发生什么?

linux - 如何显示 Bash 字符串中包含的唯一单词?

ssh - 如何通过ssh在远程计算机上运行程序(在本地计算机上编译)?

c++ - 如何从我的 Windows 笔记本电脑轻松设计基于 Linux 的终端应用程序?

bash - 在 Hudson 调用的脚本中运行时,cp 命令失败

linux - SCP 一个文件的第一行到另一个系统

linux - 没有足够的内存来构建 phantom.js - 怎么办?

linux - 使用 GOLANG 获取系统唯一 UUID

docker - Docker-ASP.CORE 2.2应用程序和SSH

git - 在 Kubernetes pod 中克隆一个安全的 git 存储库