我在 gitlab ci 上运行它,它适用于常规 ssh(从 gitlab ci 文档复制):
eval $(ssh-agent -s)
ssh-add <(echo "$SSH_PRIVATE_KEY")
mkdir -p ~/.ssh
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
这给了我
Identity added: /dev/fd/63 (/dev/fd/63)
但是,当我尝试 rsync 时出现错误:
Warning: Permanently added '*****' (ECDSA) to the list of known hosts.
Permission denied, please try again.
Permission denied, please try again.
user@server: Permission denied (publickey,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.3]
为什么 ssh 命令是 rsync 不能使用添加的身份?
我也可以这样做,以解决 rsync 问题。
eval $(ssh-agent -s)
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-add
这给了我
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)
哪个 rsync能够使用,很可能是因为它在假定的位置。
这是否意味着 rsync 使用它自己的 ssh 实现而不是本地系统上的 ssh-agent?