aboutsummaryrefslogtreecommitdiff
path: root/ssh.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-12 22:37:51 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-12 22:37:51 +0800
commit11a8f2889e874ecebdbc49a6887918c7b043c503 (patch)
tree0ead7076fe6df7a1edf6d3a54963ae328a2f0084 /ssh.go
parentREADME.md: Update about SSH implementation (diff)
downloadforge-11a8f2889e874ecebdbc49a6887918c7b043c503.tar.gz
forge-11a8f2889e874ecebdbc49a6887918c7b043c503.tar.zst
forge-11a8f2889e874ecebdbc49a6887918c7b043c503.zip
{ssh,global}.go, index.html: Add global data containing ssh fp
Diffstat (limited to 'ssh.go')
-rw-r--r--ssh.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/ssh.go b/ssh.go
index 26370c7..a08e20c 100644
--- a/ssh.go
+++ b/ssh.go
@@ -11,6 +11,10 @@ import (
go_ssh "golang.org/x/crypto/ssh"
)
+var server_public_key_string string
+var server_public_key_fingerprint string
+var server_public_key go_ssh.PublicKey
+
func serve_ssh() error {
host_key_bytes, err := os.ReadFile(config.SSH.Key)
if err != nil {
@@ -22,6 +26,10 @@ func serve_ssh() error {
return err
}
+ server_public_key = host_key.PublicKey()
+ server_public_key_string = string(go_ssh.MarshalAuthorizedKey(server_public_key))
+ server_public_key_fingerprint = string(go_ssh.FingerprintSHA256(server_public_key))
+
server := &glider_ssh.Server{
Handler: func(session glider_ssh.Session) {
client_public_key := session.PublicKey()