mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 01:39:34 +08:00
adding reading agent ssh key from file
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"io/ioutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -25,7 +26,16 @@ func main() {
|
|||||||
if pubKeyEnv, exists := os.LookupEnv("KEY"); exists {
|
if pubKeyEnv, exists := os.LookupEnv("KEY"); exists {
|
||||||
pubKey = []byte(pubKeyEnv)
|
pubKey = []byte(pubKeyEnv)
|
||||||
} else {
|
} else {
|
||||||
log.Fatal("KEY environment variable is not set")
|
keyFile := os.Getenv("KEY_FILE")
|
||||||
|
if keyFile != "" {
|
||||||
|
if keyData, err := ioutil.ReadFile(keyFile); err == nil {
|
||||||
|
pubKey = keyData
|
||||||
|
} else {
|
||||||
|
log.Fatalf("Failed to read key from file '%s': %v", keyFile, err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Fatal("KEY environment variable is not set, and KEY_FILE environment variable is not set")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addr := ":45876"
|
addr := ":45876"
|
||||||
|
Reference in New Issue
Block a user