ssh - 使用 rsync 和 ssh keygen
问题描述
我有一个 Debian 服务器,我想制作一个 cron 来将数据从我的服务器保存到连接到我的 mac 的远程硬盘驱动器。
所以,我做了这个正确运行的命令:
rsync -ah -progress -delete -e ssh xxxxxxx@1xx.1xx.1xx.1xx:/var/www/html/AccesBD/file /Volumes/USB-HDD
但我必须输入密码。
我使用 ssh-keygen 制作了文件 id_rsa_lb(不是 id_rsa),然后将其发送
ssh-copy-id -i ~/.ssh/id_rsa_lb.pub 1xx.1xx.1xx.1xx
该命令ssh -i ~/.ssh/id_rsa_lb lxxxxxxxxxx@1xx.1xx.1xx.1xx
运行正确,不需要任何密码。没关系。
但是当我尝试使用 ssh/id_rsa_lb 运行 rsync 时,出现错误:
rsync -ah -progress -delete -e ssh -i ~/.ssh/id_rsa_lb lxxxxxxxxx@1xx.1xx.1xx.1xx /var/opt/file /Volumes/USB-HDD
rsync: link_stat "/Users/yyyyy_yyyyy/.ssh/lxxxxxxxxx@1xx.1xx.1xx.1xx" failed: No such file or directory (2)
rsync: link_stat "/var/opt/base.sql" failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-54/rsync/main.c(996) [sender=2.6.9]
你能告诉我有什么问题吗?
谢谢
解决方案
使用引号,-e
只需要一个参数。
rsync user@host:src_path local_dest_path ... -e "ssh -i ~/.ssh/id_rsa_lb"
推荐阅读
- javascript - 在 Jinja 模板中更改 h1 标签中某个部分的样式
- java - Hibernate:将两列映射到 HashMap 的键和值
- python - 如何在 tkinter 上隐藏和显示画布项目?
- chromium - 如何在运行 puppeteer 抓取脚本时停止打开 chromium 浏览器?
- wso2 - 启用 GroupExtractor 时 wso2am-2.6.0 无法生成令牌
- typescript - 击败阵列
和 IObservableArray 不兼容 - python - SQLAlchemy 对求和连接进行排序和分组
- cmake - CMake - 单个库的 BUILD_SHARED_LIBS
- jenkins - 将附件从 Jenkins 发送到团队
- php - 如何在php中同时使用复选框和输入类型号