Skip to main content

Command Palette

Search for a command to run...

github action CI报错的问题:权限被拒,请再试一次

Published
3 min readView as Markdown
Run easingthemes/ssh-deploy@v5.0.0
[DIR] Creating /home/runner/.ssh dir in workspace ***
 [DIR] dir created.
[FILE] writing /home/runner/.ssh/known_hosts file ... 0
 [SSH] known_hosts file ensured /home/runner/.ssh
 [DIR] /home/runner/.ssh dir exist
[FILE] writing /home/runner/.ssh/deploy_key_***_1764850308901 file ... 3243
 [SSH] key added to `.ssh` dir  /home/runner/.ssh deploy_key_***_1764850308901
rsync  version 3.2.7  protocol version 31
Copyright (C) 1996-2022 by Andrew Tridgell, Wayne Davison, and others.
Web site: https://rsync.samba.org/
Capabilities:
    64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
    socketpairs, symlinks, symtimes, hardlinks, hardlink-specials,
    hardlink-symlinks, IPv6, atimes, batchfiles, inplace, append, ACLs,
    xattrs, optional secluded-args, iconv, prealloc, stop-at, no crtimes
Optimizations:
    SIMD-roll, no asm-roll, openssl-crypto, no asm-MD5
Checksum list:
    xxh128 xxh3 xxh64 (xxhash) md5 md4 sha1 none
Compress list:
    zstd lz4 zlibx zlib none
Daemon auth list:
    sha512 sha256 sha1 md5 md4
运行 easingthemes/ssh-deploy@v5.0.0
[DIR]在工作区中创建 /home/runner/.ssh dir ***
   [DIR] dir 创建。
[文件] 写入 /home/runner/.ssh/known_hosts 文件 ... 0
   [SSH] known_hosts 文件确保 /home/runner/.ssh
   [DIR] /home/runner/.ssh dir 存在
[文件] 写入 /home/runner/.ssh/deploy_key_***_1764850308901 文件 ... 3243
   [SSH] 键加到 '.ssh' 后面,底音 /home/runner/.ssh 的 deploy_key__1764850308901
rsync 版本 3.2.7 协议版本 31
版权所有 (C) 1996-2022,归安德鲁·特里格尔、韦恩·戴维森等人所有。
网站:https://rsync.samba.org/
能力:
64 位文件,64 位 inum,64 位时间戳,64 位长 int,
套接字对、符号链、符号、硬链、硬链-特殊,
硬链-符号链接、IPv6、atimes、批处理文件、置入、附加、ACL,
XATTRS,可选的 Seluded-ARGS,iconv,prealloc,stop-at,无 crtimes
优化:
SIMD-roll,无 asm-roll,openssl-crypto,无 asm-MD5
校验和列表:
xxh128 xxh3 xxh64 (xxhash) MD5 MD4 SHA1 无
压缩列表:
ZSTD LZ4 ZLIBX ZLIB None
守护进程认证列表:
SHA512 SHA256 SHA1 MD5 MD4rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
are welcome to redistribute it under certain conditions.  See the GNU
General Public Licence for details.
 [CLI] Rsync exists
[Rsync] Starting Rsync Action: /home/runner/work/looking-for-dog/looking-for-dog/dist/ to ***@***:/var/www/looking-for-dog
[Rsync] excluding folders /dist/,/node_modules/
Warning: Permanently added '***' (ED25519) to the list of known hosts.
RSYNC 完全没有保修。这是免费软件,你也没问题
欢迎在特定条件下重新分发。参见 GNU
详情请参阅公共许可证。
   [CLI] Rsync 存在
[同步]启动 Rsync 动作:/home/runner/work/looking-for-dog/looking-for-dog/dist/ 发给 @***:/var/www/looking-for-dog
[Rsync] 不包括文件夹 /dist/,/node_modules/
警告:已永久添加“***”(ED25519)到已知主持人列表中。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(232) [sender=3.2.7]
rsync:连接意外关闭(目前接收 0 字节)[发送端]
rsync 错误:IO.C(232) [发送者=3.2.7] 的未解释错误(代码 255) [Rsync] error: 
Error: rsync exited with code 255
    at ChildProcess.<anonymous> (/home/runner/work/_actions/easingthemes/ssh-deploy/v5.0.0/dist/index.js:2:2603)
rsync /home/runner/work/looking-for-dog/looking-for-dog/dist/ ***@***:/var/www/looking-for-dog --rsh "ssh -p 22 -i /home/runner/.ssh/deploy_key_***_1764850308901 -o StrictHostKeyChecking=no" --recursive --exclude=/dist/ --exclude=/node_modules/ -rlgoDzvc -i
    at ChildProcess.emit (node:events:524:28)
    at ChildProcess._handle.onexit (node:internal/child_process:293:12) {
  code: 255
}
 [Rsync] stderr: 
Warning: Permanently added '***' (ED25519) 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(232) [sender=3.2.7]
   [Rsync] 错误:
错误:rsync 退出,代码为 255
在 ChildProcess。<anonymous> (/home/runner/work/_actions/easingthemes/ssh-deploy/v5.0.0/dist/index.js:22603)
rsync /home/runner/work/looking-for-dog/looking-for-dog/dist/ ***@***:/var/www/looking-for-dog --rsh “ssh -p 22 -i /home/runner/.ssh/deploy_key__1764850308901 -o StrictHostKeyChecking=no” --递归 --exclude=/dist/ --exclude=/node_modules/ -rlgoDzvc -i
在 ChildProcess.emit (node:events:52428)
at ChildProcess._handle.onexit (node:internal/child_process:29312) {
代码:255
}
   [Rsync] stderr:
警告:已永久添加“***”(ED25519)到已知主持人列表中。
权限被拒,请再试一次。
权限被拒,请再试一次。
@***:权限被拒(公开密钥,密码)。
rsync:连接意外关闭(目前接收 0 字节)[发送端]
rsync 错误:IO.C(232) [发送者=3.2.7] 的未解释错误(代码 255) [Rsync] stdout: 
   [Rsync] 状态:  [Rsync] command: 
================================================================

   [Rsync] 命令:
================================================================
================================================================
Error: R] rsync exited with code 255
================================================================
错误:R] rsync 退出,代码 255Warning: Permanently added '***' (ED25519) 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(232) [sender=3.2.7]
警告:已永久添加“***”(ED25519)到已知主持人列表中。
权限被拒,请再试一次。
权限被拒,请再试一次。
@***:权限被拒(公开密钥,密码)。
rsync:连接意外关闭(目前接收 0 字节)[发送端]
rsync 错误:IO.C(232) [发送者=3.2.7] 的未解释错误(代码 255

这是报错信息

排查发现是ssh 公钥私钥配不上的问题

假如把公钥放到vps服务器

ssh root@your-vps-ip
echo "PASTE_PUBLIC_KEY_HERE" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

本地ssh登陆

ssh -i ~/.ssh/looking_for_dog_deploy root@your-vps-ip

是可以登陆成功的。但是设置 ~/.ssh/looking_for_dog_deploy 为github action的 secrets and varibales 的VPS_SSH_KEY,发现自动构建是失败的。原因是这个私钥文件里有两个私钥。

vi ~/.ssh/looking_for_dog_deploy

发现文本是这样的

-----BEGIN RSA PRIVATE KEY-----
MIIJJwIBAAKCAgEAoQBXvjSUdMuYUlOt4ljwIljKEiqtoeJ4JrMui/I6clclr4qN
...
-----BEGIN RSA PRIVATE KEY-----
MIIJKQIBAAKCAgEAxRX7cRlq3qfQJStEyOa6iNwlAdttj+Y1euirqxVKLRyk0afz
...
-----END RSA PRIVATE KEY-----

其实有两个private key,具体哪个是正确的,需要自己把这个文件拆分成两个a.pemb.pemchmod 600 a.pem更改文件权限,只有owner可以编辑。然后 ssh -i a.pem root@your-vps-ip 自己去测试,哪个是正确的私钥。