powershell instructions did not work when mukltiple ssh keys were configured.

Also ignoring empty lines in the input.
This commit is contained in:
Erik Brakkee 2024-09-04 22:04:13 +02:00 committed by Erik Brakkee
parent 9508fca88f
commit a0ae2d7d97
2 changed files with 11 additions and 9 deletions

8
.idea/.gitignore vendored
View File

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -2,6 +2,7 @@ package ui
import (
"fmt"
"strings"
)
type UsageInputs struct {
@ -38,12 +39,21 @@ func addSshKeys(shell Shell, keys []string) string {
}
res := ""
for index, key := range keys {
key = strings.TrimSpace(key)
if key == "" {
continue
}
operator := ">>"
if index == 0 {
operator = ">"
}
if shell == POWERSHELL {
res += fmt.Sprintf(`"%s" | Out-File -FilePath ".authorized_keys" -Encoding ASCII<br/>`, key)
append := ""
if index > 0 {
append = "-Append "
}
res += fmt.Sprintf(`"%s" | Out-File %s-FilePath ".authorized_keys" -Encoding ASCII<br/>`,
key, append)
} else {
res += fmt.Sprintf(" echo %s%s%s %s .authorized_keys<br/>", quote, key, quote,
operator)