Ejemplo n.º 1
0
func verifyCreds(ctx *infrastructure.Context) error {
	found, err := sshagent.HasKey(ctx.InfraCreds["ssh_public_key"])
	if err != nil {
		return sshAgentError(err)
	}
	if !found {
		ok, _ := guessAndLoadPrivateKey(
			ctx.Ui, ctx.InfraCreds["ssh_public_key_path"])
		if ok {
			ctx.Ui.Message(
				"A private key was found and loaded. Otto will now check\n" +
					"the SSH Agent again and continue if the correct key is loaded")

			found, err = sshagent.HasKey(ctx.InfraCreds["ssh_public_key"])
			if err != nil {
				return sshAgentError(err)
			}
		}
	}

	if !found {
		return sshAgentError(fmt.Errorf(
			"You specified an SSH public key of: %q, but the private key from this\n"+
				"keypair is not loaded the SSH Agent. To load it, run:\n\n"+
				"  ssh-add [PATH_TO_PRIVATE_KEY]",
			ctx.InfraCreds["ssh_public_key_path"]))
	}
	return nil
}
Ejemplo n.º 2
0
func verifyCreds(ctx *infrastructure.Context) error {
	found, err := sshagent.HasKey(ctx.InfraCreds["ssh_public_key"])
	if err != nil {
		return sshAgentError(err)
	}
	if !found {
		ok, _ := guestAndLoadPrivateKey(ctx.Ui, ctx.InfraCreds["ssh_public_key_path"])
		if ok {
			ctx.Ui.Message(
				"发现一个private key并装载。Otto将会检查\n" +
					"SSH Agent如果正确的key被装载")
			found, err = sshagent.HasKey(ctx.InfraCreds["ssh_public_key"])
			if err != nil {
				return sshAgentError(err)
			}
		}
	}

	if !found {
		return sshAgentError(fmt.Errorf(
			"You specified an SSH public key of: %q, but the private key from this\n"+
				"keypair is not loaded the SSH Agent. To load it, run:\n\n"+
				"  ssh-add [PATH_TO_PRIVATE_KEY]",
			ctx.InfraCreds["ssh_public_key_path"]))
	}
	return nil
}