bug(cli): Correctly generate private key file (#2274)

This commit is contained in:
Louis Ruch authored and GitHub committed 2022-07-21 15:07:01 -07:00
1 parent d37f80879a
commit d6c1402223
1 file changed
+6
+6
View File
@@ -111,6 +111,12 @@ func (s *sshFlags) buildArgs(c *Command, port, ip, addr string, creds credential
}
return nil
})
// SSH requires the private key file to end with a newline.
// When injesting a ssh_private_key from a file:// Boundary calls strings.TrimSpace
// which will also trim newlines.
if !strings.HasSuffix(privateKey, "\n") {
privateKey = fmt.Sprintln(privateKey)
}
_, err = pkFile.WriteString(privateKey)
if err != nil {
return nil, nil, credentials{}, fmt.Errorf("Error writing private key file to %s: %w", pkFile.Name(), err)