
使用 crontab 来定时执行.sh 把文件备份到 github,会出现有时需要手动执行一次“ssh-agent bash”在执行.sh 才成功,有时就不用,以下是错误内容和.sh 源码 ###报错内容:
Could not open a connection to your authentication agent. [email protected]: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ###.sh 文件内容
#!/bin/bash cd /root/mc/worlds git add -A git commit -m "backup" ssh-add /root/github git push -u origin master 1 Showfom PRO = = 很少听说备份到 github 的 |
2 joeyv2 OP @Showfom 主要还是 SSH 密钥管理器不工作了,需要手动启动。sh 文件执行 ssh-agent bash 有没反应。备份地点用 gitee 吗? |
3 dzdh Mar 22, 2021 没看懂 难道不是 ~/$USER/.ssh/config 配置好然后直接 sudo -u $USER git -C $path push 么 |
4 joeyv2 OP |
7 dzdh Mar 22, 2021 @joeyv2 国内就是 aliyun oss 100%兼容 S3 协议。控制台可以开启文件版本控制。可以挂载成本地盘的形式直接在服务器上进行读写无需任何其他操作。 |
8 python4 Mar 22, 2021 那就把 ssh-agent 命令加到 shell 里不行吗? |