linux - 如何将文件从 linux 实例正确复制到 aws ec2 实例?
问题描述
我正在尝试使用在 linux 机器上运行的 jenkins 将一些文件从 linux 服务器复制到 ec2 实例,我面临以下问题:
debug1: read_passphrase: can't open /dev/tty: No such file or directory
Host key verification failed.
lost connection
复制我使用的命令:
sh 'scp -v -i /path/key.pem /path_to_my_file/file.txt user@host:/path_to_target
'
解决方案
通常我们期望~/.ssh/
文件夹中的密钥,但如果是 Jenkins,最好使用绝对路径。所以可能有两个原因
- 没有选择正确的密钥,传递完整路径
/absolute_path/key.pem
Host key verification failed 错误消息意味着您的 SSH 客户端已比较接收到的远程服务器的公钥,并注意到它与 ~/.ssh/known_hosts 文件中存储的主机密钥版本不匹配。
所以试试-o StrictHostKeyChecking=no
如果问题仍然存在,您可以发布完整的调试日志。
如果有权限问题,你应该复制到用户有权限的位置。
应该像
scp -v -i /path/key.pem /path_to_my_file/file.txt user@host:/home/user/path_to_target'
推荐阅读
- mongodb - 如何获取 Mongodb 集合创建脚本?
- apache-flink - Flink SQL (V 1.12.1) 无法从 Kinesis 流中读取 debezium 更新日志
- javascript - 如何修复 react-timeago 不自行更新
- microsoft-dynamics - 动态门户 启用门户的上次登录联系人
- c# - 如何通过 Swagger UI 通过 ASP.net C# 控制器上传小文件?
- c++ - 我如何弄清楚为什么我的默认移动赋值运算符与“隐式异常规范”不匹配
- autodesk-forge - 如何使用窗口选择来选择对象 feom 2d sheet
- javascript - 我怎样才能在 discord.js v12 中锁定这个命令?
- php - 如何在 Laravel 的文件上传中检测特定的字符名称?
- python - 将 concurrent.futures.ProcessPoolExecutor 与 DataFrame.GroupBy 一起使用