hashicorp/packer · error

only one of ssh_agent_auth, ssh_password, and ssh_private_ke

Error message

only one of ssh_agent_auth, ssh_password, and ssh_private_key_file must be specified

What it means

Validation guard raised during the null builder's Prepare. The null builder has no machine image output, so the only thing it does is open a communicator; exactly one SSH authentication method must be configured. This error fires when the template sets more than one of ssh_agent_auth, ssh_password, and ssh_private_key_file at the same time, making the auth method ambiguous. Fix the template by keeping only one of the three communicator auth settings.

Source

Thrown at builder/null/config.go:60

			errs = packersdk.MultiErrorAppend(errs,
				fmt.Errorf("a Host must be specified, please reference your communicator documentation"))
		}

		if c.CommConfig.User() == "" {
			errs = packersdk.MultiErrorAppend(errs,
				fmt.Errorf("a Username must be specified, please reference your communicator documentation"))
		}

		if !c.CommConfig.SSHAgentAuth && c.CommConfig.Password() == "" && c.CommConfig.SSHPrivateKeyFile == "" {
			errs = packersdk.MultiErrorAppend(errs,
				fmt.Errorf("one authentication method must be specified, please reference your communicator documentation"))
		}

		if (c.CommConfig.SSHAgentAuth &&
			(c.CommConfig.SSHPassword != "" || c.CommConfig.SSHPrivateKeyFile != "")) ||
			(c.CommConfig.SSHPassword != "" && c.CommConfig.SSHPrivateKeyFile != "") {
			errs = packersdk.MultiErrorAppend(errs,
				fmt.Errorf("only one of ssh_agent_auth, ssh_password, and ssh_private_key_file must be specified"))

		}
	}

	if errs != nil && len(errs.Errors) > 0 {
		return nil, errs
	}

	return nil, nil
}

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Keep only one auth field: either ssh_agent_auth, ssh_password, or ssh_private_key_file
  2. If using a key file, remove the password and disable agent auth
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at builder/null/config.go:60 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05). Data as JSON: /api/errors/42c6cded22b54197. Report an issue: GitHub.