powershell instructions did not work when mukltiple ssh keys were configured.
Also ignoring empty lines in the input.
This commit is contained in:
parent
9508fca88f
commit
a0ae2d7d97
8
.idea/.gitignore
vendored
8
.idea/.gitignore
vendored
@ -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
|
|
@ -2,6 +2,7 @@ package ui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UsageInputs struct {
|
type UsageInputs struct {
|
||||||
@ -38,12 +39,21 @@ func addSshKeys(shell Shell, keys []string) string {
|
|||||||
}
|
}
|
||||||
res := ""
|
res := ""
|
||||||
for index, key := range keys {
|
for index, key := range keys {
|
||||||
|
key = strings.TrimSpace(key)
|
||||||
|
if key == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
operator := ">>"
|
operator := ">>"
|
||||||
if index == 0 {
|
if index == 0 {
|
||||||
operator = ">"
|
operator = ">"
|
||||||
}
|
}
|
||||||
if shell == POWERSHELL {
|
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 {
|
} else {
|
||||||
res += fmt.Sprintf(" echo %s%s%s %s .authorized_keys<br/>", quote, key, quote,
|
res += fmt.Sprintf(" echo %s%s%s %s .authorized_keys<br/>", quote, key, quote,
|
||||||
operator)
|
operator)
|
||||||
|
Loading…
Reference in New Issue
Block a user