X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/08123387faf00b0af64ea01f7196d8c5ca3fae1e..4257184a0fd276af7e1741dda8a7468a30b4a9c6:/lib/dispatchcloud/worker/verify.go diff --git a/lib/dispatchcloud/worker/verify.go b/lib/dispatchcloud/worker/verify.go index e22c85d009..c718702101 100644 --- a/lib/dispatchcloud/worker/verify.go +++ b/lib/dispatchcloud/worker/verify.go @@ -21,13 +21,17 @@ var ( instanceSecretLength = 40 // hex digits ) -type tagVerifier struct { +type TagVerifier struct { cloud.Instance + Secret string } -func (tv tagVerifier) VerifyHostKey(pubKey ssh.PublicKey, client *ssh.Client) error { - expectSecret := tv.Instance.Tags()[tagKeyInstanceSecret] - if err := tv.Instance.VerifyHostKey(pubKey, client); err != cloud.ErrNotImplemented || expectSecret == "" { +func (tv TagVerifier) InitCommand() cloud.InitCommand { + return cloud.InitCommand(fmt.Sprintf("umask 0177 && echo -n %q >%s", tv.Secret, instanceSecretFilename)) +} + +func (tv TagVerifier) VerifyHostKey(pubKey ssh.PublicKey, client *ssh.Client) error { + if err := tv.Instance.VerifyHostKey(pubKey, client); err != cloud.ErrNotImplemented || tv.Secret == "" { // If the wrapped instance indicates it has a way to // verify the key, return that decision. return err @@ -49,7 +53,7 @@ func (tv tagVerifier) VerifyHostKey(pubKey ssh.PublicKey, client *ssh.Client) er if err != nil { return err } - if stdout.String() != expectSecret { + if stdout.String() != tv.Secret { return errBadInstanceSecret } return nil