~dave-cheney/juju-core/110-remove-instance-newaddresses

« back to all changes in this revision

Viewing changes to utils/ssh/authorisedkeys.go

  • Committer: Tarmac
  • Author(s): Ian Booth
  • Date: 2014-03-31 10:34:09 UTC
  • mfrom: (2512.1.2 replace-ssh-keys-fix)
  • Revision ID: tarmac-20140331103409-db7oeup40elyxamc
[r=wallyworld] Improve ssh.ReplaceKeys

ReplaceKeys is used by the authentication worker
to write ssh keys to ~/.ssh/authorized_keys. It
merges existing keys with those added to Juju. It
checks that all keys to be written have comments, but
existing keys may not have comments. The check for key
comment is done as any keys are added to Juju so the
check in ReplaceKeys can be removed.

https://codereview.appspot.com/82480043/

Show diffs side-by-side

added added

removed removed

Lines of Context:
264
264
                        existingNonKeyLines = append(existingNonKeyLines, line)
265
265
                }
266
266
        }
267
 
        for _, newKey := range newKeys {
268
 
                _, comment, err := KeyFingerprint(newKey)
269
 
                if err != nil {
270
 
                        return err
271
 
                }
272
 
                if comment == "" {
273
 
                        return fmt.Errorf("cannot add ssh key without comment")
274
 
                }
275
 
        }
276
267
        return writeAuthorisedKeys(user, append(existingNonKeyLines, newKeys...))
277
268
}
278
269