mirror of https://github.com/kubernetes/kops.git
Parse SSH public keys with 'odd' whitespace
e.g. a key with \r instead of spaces Fix #63
This commit is contained in:
parent
a91cc6e9a4
commit
7347f1815a
|
@ -81,7 +81,7 @@ func (e *SSHKey) Find(c *fi.Context) (*SSHKey, error) {
|
|||
|
||||
// computeAWSKeyFingerprint computes the AWS-specific fingerprint of the SSH public key
|
||||
func computeAWSKeyFingerprint(publicKey string) (string, error) {
|
||||
tokens := strings.Split(publicKey, " ")
|
||||
tokens := strings.Fields(publicKey)
|
||||
if len(tokens) < 2 {
|
||||
return "", fmt.Errorf("error parsing SSH public key: %q", publicKey)
|
||||
}
|
||||
|
|
|
@ -38,6 +38,12 @@ func TestFingerprint_RsaKeyEncrypted(t *testing.T) {
|
|||
checkFingerprintEqual(t, key, "c9:c5:05:5e:ea:54:fc:a4:7c:7c:75:5c:d2:71:5e:40")
|
||||
}
|
||||
|
||||
func TestFingerprint_TrickyWhitespace(t *testing.T) {
|
||||
// No name, \r instead of whitespace
|
||||
key := "ssh-rsa\rAAAAB3NzaC1yc2EAAAADAQABAAABAQCySdqIU+FhCWl3BNrAvPaOe5VfL2aCARUWwy91ZP+T7LBwFa9lhdttfjp/VX1D1/PVwntn2EhN079m8c2kfdmiZ/iCHqrLyIGSd+BOiCz0lT47znvANSfxYjLUuKrWWWeaXqerJkOsAD4PHchRLbZGPdbfoBKwtb/WT4GMRQmb9vmiaZYjsfdPPM9KkWI9ECoWFGjGehA8D+iYIPR711kRacb1xdYmnjHqxAZHFsb5L8wDWIeAyhy49cBD+lbzTiioq2xWLorXuFmXh6Do89PgzvHeyCLY6816f/kCX6wIFts8A2eaEHFL4rAOsuh6qHmSxGCR9peSyuRW8DxV725x\r"
|
||||
checkFingerprintEqual(t, key, "85:a6:f4:64:b7:8f:4a:75:f1:ed:f9:26:1b:67:5f:f2")
|
||||
}
|
||||
|
||||
func TestFingerprint_DsaKey(t *testing.T) {
|
||||
key := "ssh-dss AAAAB3NzaC1kc3MAAACBAIcCTu3vi9rNjsnhCrHeII7jSN6/FmnIdy09pQAsMAGGvCS9HBOteCKbIyYQQ0+Gi76Oui7cJ2VQojdxOxeZPoSP+QYnA+CVYhnowVVLeRA9VBQG3ZLInoXaqe3nR4/OXhY75GmYShBBPTQ+/fWGX9ltoXfygSc4KjhBNudvj75VAAAAFQDiw8A4MhY0aHSX/mtpa7XV8+iS6wAAAIAXyQaxM/dk0o1vBV3H0V0lGhog3mF7EJPdw7jagYvXQP1tAhzNofxZVhXHr4wGfiTQv9j5plDqQzCI/15a6DRyo9zI+zdPTR41W3dGrk56O2/Qxsz3/vNip5OwpOJ88yMmBX9m36gg0WrOXcZDgErhvZWRt5cXa9QjVg/KpxYLPAAAAIB8e5M82IiRLi+k1k4LsELKArQGzVkPgynESfnEXX0TKGiR7PJvBNGaKnPJtJ0Rrc38w/hLTeklroJt9Rdey/NI9b6tc+ur2pmJdnYppnNCm03WszU4oFD/7KIqR84Hf0fMbWd1hRvznpZhngZ505KNsL+ck0+Tlq6Hdhe2baXJcA== justin@machine"
|
||||
checkFingerprintError(t, key, "AWS can only import RSA keys")
|
||||
|
|
Loading…
Reference in New Issue