Fix obtaining host key
This commit is contained in:
parent
d465421fa0
commit
8c8ecc6379
@ -292,13 +292,25 @@ func (c *Container) GetHostKey() (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Loop over lines and search for localhost ssh
|
||||||
|
line := ""
|
||||||
if hostKeyRaw != nil {
|
if hostKeyRaw != nil {
|
||||||
hostKeyRawString := strings.TrimSpace(string(*hostKeyRaw))
|
for _, line = range strings.Split(string(*hostKeyRaw), "\n") {
|
||||||
parts := strings.SplitN(hostKeyRawString, " ", 2)
|
if strings.HasPrefix(line, "localhost ssh") {
|
||||||
|
line = strings.TrimSpace(line)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if line == "" {
|
||||||
|
return "", errors.New("key not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
parts := strings.SplitN(line, " ", 2)
|
||||||
if len(parts) > 1 {
|
if len(parts) > 1 {
|
||||||
return parts[1], nil
|
return parts[1], nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return "", errors.New("key not found")
|
return "", errors.New("key not found")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user