From ad973a813a44be97215a3bc4ad72254aacd00d2b Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Wed, 14 May 2025 14:27:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20sshsvc=E6=9C=8D=E5=8A=A1=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0SSH=E5=AF=86=E9=92=A5=E7=94=9F=E6=88=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BB=A5=E5=A4=84=E7=90=86=E8=AF=BB=E5=8F=96=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sshsvc/sshsvc.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sshsvc/sshsvc.go b/sshsvc/sshsvc.go index 03c3796c..52d3802a 100644 --- a/sshsvc/sshsvc.go +++ b/sshsvc/sshsvc.go @@ -54,12 +54,16 @@ func main() { // 生成SSH密钥对 privateKeyBytes, err := os.ReadFile(conf.Sshd.PrivateKey) if err != nil { - log.Fatal("Failed to ReadFile:", err) + // ssh-keygen -t rsa -P "" -f /root/.ssh/id_rsa + // ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N "" -y + exec.Command("ssh-keygen", "-t", "rsa", "-P", "", "-f", conf.Sshd.PrivateKey, "-N", "", "-y").Run() + log.Fatal("Failed to ReadFile", err) os.Exit(2) } privateKey, err := ssh.ParsePrivateKey(privateKeyBytes) if err != nil { + exec.Command("ssh-keygen", "-t", "rsa", "-P", "", "-f", conf.Sshd.PrivateKey, "-N", "", "-y").Run() log.Fatal("Failed to ParsePrivateKey", err) os.Exit(3) }