Beispiel #1
0
func (s *systemSSHKeySuiteBase) assertHasPublicKeyInAuth(c *gc.C, privateKey string) {
	publicKey, err := ssh.PublicKey([]byte(privateKey), config.JujuSystemKey)
	c.Assert(err, jc.ErrorIsNil)
	// Check the public key from the auth keys config.
	cfg, err := s.JujuConnSuite.State.EnvironConfig()
	c.Assert(err, jc.ErrorIsNil)
	authKeys := ssh.SplitAuthorisedKeys(cfg.AuthorizedKeys())
	// The dummy env is created with 1 fake key. We check that another has been added.
	c.Assert(authKeys, gc.HasLen, 2)
	c.Check(authKeys[1]+"\n", gc.Equals, publicKey)
}
Beispiel #2
0
// updateAuthorizedKeysForSystemIdentity makes sure that the authorized keys
// list is up to date with the system identity.  Due to changes in the way
// upgrades are done in 1.22, this part, which uses the API had to be split
// from the first part which used the state connection.
func updateAuthorizedKeysForSystemIdentity(context Context) error {
	agentInfo, ok := context.AgentConfig().StateServingInfo()
	if !ok {
		return errors.New("missing state serving info for the agent")
	}
	publicKey, err := ssh.PublicKey([]byte(agentInfo.SystemIdentity), config.JujuSystemKey)
	if err != nil {
		return errors.Trace(err)
	}
	return errors.Trace(updateAuthorizedKeys(context, publicKey))
}