fix(server-monitor): support Base64 SSH private keys and passphrase - #2
Open
KuGouGo wants to merge 1 commit into
Open
fix(server-monitor): support Base64 SSH private keys and passphrase#2KuGouGo wants to merge 1 commit into
KuGouGo wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题背景
server-monitor当前直接把模块环境变量中的privateKey原样传给ctx.ssh.connect()。在 Egern 模块编辑页粘贴多行 PEM 私钥时,私钥可能因换行保存/粘贴方式发生变化,底层 libssh2 随后在认证前报错:服务器端日志可见客户端已经连接到 22 端口,但在尝试认证前断开,因此问题发生在客户端私钥解析阶段,而非服务器公钥授权、文件权限或网络连接。
此外,Egern 官方
ctx.ssh.connect(config)API 已提供可选的passphrase字段,但原模块尚未透传,带口令的私钥无法使用。修改内容
privateKeyBase64环境变量,允许用户将完整 PEM 私钥编码为单行 Base64 后填写,避免多行输入带来的换行损坏。\\n;privateKey字段,兼容已有配置;当两个字段同时存在时,优先使用privateKeyBase64。passphrase并透传给ctx.ssh.connect()。兼容性
验证
node --check。git diff --check通过。