Renamed authorized_keys public key function.

This commit is contained in:
Stephen Fox 2019-02-04 14:27:14 -05:00
parent d465231e63
commit f2c11b55be
3 changed files with 5 additions and 5 deletions

View File

@ -59,7 +59,7 @@ func (s *StepSshKeyPair) Run(_ context.Context, state multistep.StateBag) multis
s.Comm.SSHKeyPairName = kp.Name()
s.Comm.SSHTemporaryKeyPairName = kp.Name()
s.Comm.SSHPrivateKey = kp.PrivateKeyPemBlock()
s.Comm.SSHPublicKey = kp.PublicKeyAuthorizedKeysFormat(ssh.UnixNewLine)
s.Comm.SSHPublicKey = kp.PublicKeyAuthorizedKeysLine(ssh.UnixNewLine)
s.Comm.SSHClearAuthorizedKeys = true
ui.Say(fmt.Sprintf("Created ephemeral SSH key pair of type %s", kp.Description()))

View File

@ -210,10 +210,10 @@ type KeyPair interface {
// format in a Privacy-Enhanced Mail (PEM) block.
PrivateKeyPemBlock() []byte
// PublicKeyAuthorizedKeysFormat returns a slice of bytes
// PublicKeyAuthorizedKeysLine returns a slice of bytes
// representing the public key in OpenSSH authorized_keys format
// with the specified new line.
PublicKeyAuthorizedKeysFormat(NewLineOption) []byte
PublicKeyAuthorizedKeysLine(NewLineOption) []byte
}
type defaultKeyPair struct {
@ -267,7 +267,7 @@ func (o defaultKeyPair) PrivateKeyPemBlock() []byte {
})
}
func (o defaultKeyPair) PublicKeyAuthorizedKeysFormat(nl NewLineOption) []byte {
func (o defaultKeyPair) PublicKeyAuthorizedKeysLine(nl NewLineOption) []byte {
result := gossh.MarshalAuthorizedKey(o.publicKey)
if len(strings.TrimSpace(o.name)) > 0 {

View File

@ -79,7 +79,7 @@ func (o expected) verifyPublicKeyAuthorizedKeysFormat(kp KeyPair) error {
}
for _, nl := range newLines {
publicKeyAk := kp.PublicKeyAuthorizedKeysFormat(nl)
publicKeyAk := kp.PublicKeyAuthorizedKeysLine(nl)
if len(publicKeyAk) < 2 {
return errors.New("expected public key in authorized keys format to be at least 2 bytes")