// Keys Get the public keys of all configured KMS keys in OpenSSH format
Keys Get the public keys of all configured KMS keys in OpenSSH format
// Keys Get the public keys of all configured KMS keys in OpenSSH format
func Keys() error {
	c := config.NewSSHrimp()
	if err := c.Read(config.GetPath()); err != nil {
		return err
	}
	for _, region := range c.CertificateAuthority.Regions {
		session := session.Must(session.NewSession(&aws.Config{
			Region: aws.String(region),
		}))
		svc := kms.New(session)
		response, err := svc.GetPublicKey(&kms.GetPublicKeyInput{
			KeyId: aws.String(c.CertificateAuthority.KeyAlias),
		})
		if err != nil {
			return err
		}
		publicKey, err := x509.ParsePKIXPublicKey(response.PublicKey)
		if err != nil {
			return err
		}
		sshPublicKey, err := ssh.NewPublicKey(publicKey)
		if err != nil {
			return err
		}
		authorizedKey := strings.TrimSuffix(string(ssh.MarshalAuthorizedKey(sshPublicKey)), "\n")
		fmt.Printf("%s sshrimp-ca@%s\n", authorizedKey, region)
	}
	return nil
}
func Keys ( ) error { c := config . NewSSHrimp ( ) if err := c . Read ( config . GetPath ( ) ) ; err != nil { return err } for _ , region := range c . CertificateAuthority . Regions { session := session . Must ( session . NewSession ( & aws . Config { Region : aws . String ( region ) , } ) ) svc := kms . New ( session ) response , err := svc . GetPublicKey ( & kms . GetPublicKeyInput { KeyId : aws . String ( c . CertificateAuthority . KeyAlias ) , } ) if err != nil { return err } publicKey , err := x509 . ParsePKIXPublicKey ( response . PublicKey ) if err != nil { return err } sshPublicKey , err := ssh . NewPublicKey ( publicKey ) if err != nil { return err } authorizedKey := strings . TrimSuffix ( string ( ssh . MarshalAuthorizedKey ( sshPublicKey ) ) , " \n " ) fmt . Printf ( " \n " , authorizedKey , region ) } return nil }
Keys Get the public keys of all configured KMS keys in OpenSSH format
Keys Get the public keys of all configured KMS keys in OpenSSH format
// For each configured region, get the public key from KMS and format it in an OpenSSH authorized_keys format // Create a new session in the correct region // Get the public key from KMS // Parse the public key from KMS // Convert the public key into an SSH public key // Generate the final string to output on stdout