通过ssh返回操作自动部署github,rsync退出,代码为255



我想使用ssh将我的NodeJS GitHub项目部署到我的VP,所以我在.github/workflows:中制作了这个脚本


name: Node CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: '10.x'
- name: Install npm dependencies
run: npm install
- name: Run build task
run: npm run build --if-present
- name: Deploy to Server
uses: easingthemes/ssh-deploy@v2.2.11
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
ARGS: "-rltgoDzvO --delete"
SOURCE: "/"
REMOTE_HOST: ${{ secrets.HOST }}
REMOTE_USER: ${{ secrets.USERNAME }}
TARGET: ${{ secrets.FOLDER_TARGET }}
EXCLUDE: "/dist/, /node_modules/"

我在我的秘密存储库密钥中输入所有信息。为了生成ssh密钥,我使用以下命令:ssh-keygen -m PEM -t rsa -b 4096没有转述。我已经在ssh_KEY值中传递了~/.ssh/id_rsa`字符串

但在所有这些之后,我在运行操作脚本时出现了以下错误:

Run easingthemes/ssh-deploy@v2.2.11
[general] GITHUB_WORKSPACE:  /home/runner/work/Litopia.fr/Litopia.fr
[SSH] Creating /home/runner/.ssh dir in  /home/runner/work/Litopia.fr/Litopia.fr
✅ [SSH] dir created.
[SSH] Creating /home/runner/.ssh/known_hosts file in  /home/runner/work/Litopia.fr/Litopia.fr
✅ [SSH] file created.
✅ Ssh key added to `.ssh` dir  /home/runner/.ssh/deploy_key
[Rsync] Starting Rsync Action: /home/runner/work/Litopia.fr/Litopia.fr// to ***@***:***
[Rsync] exluding folders /dist/,/node_modules/
⚠️ [Rsync] error:  rsync exited with code 255
⚠️ [Rsync] stderr:  Warning: Permanently added '***,82.65.27.189' (ECDSA) to the list of known hosts.
Permission denied, please try again.
Permission denied, please try again.
***@***: 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]
⚠️ [Rsync] stdout:  
⚠️ [Rsync] cmd:  rsync /home/runner/work/Litopia.fr/Litopia.fr// ***@***:*** --rsh "ssh -p 22 -i /home/runner/.ssh/deploy_key -o StrictHostKeyChecking=no" --recursive --exclude=/dist/ --exclude=/node_modules/ -rltgoDzvO --delete
1: 0x9da7c0 node::Abort() [/home/runner/runners/2.278.0/externals/node12/bin/node]
2: 0xa4e219  [/home/runner/runners/2.278.0/externals/node12/bin/node]
3: 0xba5d59  [/home/runner/runners/2.278.0/externals/node12/bin/node]
4: 0xba7b47 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/home/runner/runners/2.278.0/externals/node12/bin/node]
5: 0x13750d9  [/home/runner/runners/2.278.0/externals/node12/bin/node]

首先检查easingthemes/ssh-deploy自述中提到的公钥部分是否已添加到接收部署的服务器上的authorized_keys文件中。

尝试使用进行测试

ssh -Tv -i /home/runner/.ssh/deploy_key -o StrictHostKeyChecking=no $REMOTE_USER@$REMOTE_HOST

OP MrSolarius在评论中补充道:

我使用了我的私钥而不是公钥,所以现在它可以工作了。

这个问题也发生在我身上我做错的是从.ppk文件中复制内容。在我从记事本打开.pem文件并复制内容后,它开始工作

除此之外,我还必须启用从EC2 VPC组到任何地方的SSH端口。

最新更新