Github Actions连不上服务器问题,求指教
一. 目的
想在提交代码后触发 ssh连接,并执行服务器中的sh
文件.
二. 问题
现在执行报错:ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
三. 我的操作步骤
- 生成ssh公钥并加入到了
setting->SSH and GPG keys
中:# 生成公钥 ssh-keygen -t rsa -b 4096 -C "1****1@qq.com" # 复制公钥 cat /root/.ssh/id_rsa.pub
- 将私钥配置到
Settings->Secrets and variables -> actions
中:# 复制私钥 cat /root/.ssh/id_rsa
- 编写
yml
文件:
name: Deploy
on:
push:
branches:
- main # 监听main分支
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: 123.249.31.52
username: root
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /root/app/github-actions
./website.sh
四. 执行报错:
本作品采用《CC 协议》,转载必须注明作者和本文链接
github.com/appleboy/ssh-action/blo...
自己看吧, 上面有说明, 你这个报错也说了
警惕境外网络!