Add SSH users on subsequent coordinators & nodes

This commit is contained in:
Nils Hanke 2022-05-17 12:02:49 +02:00 committed by Nils Hanke
parent 084ed0c4ef
commit ed071d389c
5 changed files with 307 additions and 233 deletions

View file

@ -10,6 +10,7 @@ import (
"github.com/edgelesssys/constellation/coordinator/role"
"github.com/edgelesssys/constellation/coordinator/state"
"github.com/edgelesssys/constellation/coordinator/vpnapi/vpnproto"
"github.com/edgelesssys/constellation/internal/deploy/ssh"
"go.uber.org/zap"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@ -91,6 +92,14 @@ func (a *API) ActivateAsNode(stream pubproto.API_ActivateAsNodeServer) (reterr e
return status.Errorf(codes.Internal, "advance node state: %v", err)
}
// Setup SSH users for the node, if defined
if len(in.SshUserKeys) != 0 {
sshUserKeys := ssh.FromProtoSlice(in.SshUserKeys)
if err := a.core.CreateSSHUsers(sshUserKeys); err != nil {
return status.Errorf(codes.Internal, "creating SSH users on node: %v", err)
}
}
vpnPubKey, err := a.core.GetVPNPubKey()
if err != nil {
return status.Errorf(codes.Internal, "get vpn publicKey: %v", err)