hashicorp/packer · error

a Username must be specified, please reference your communic

Error message

a Username must be specified, please reference your communicator documentation

What it means

Config validation error from the null builder's Prepare: a non-"none" communicator is configured with a host but no username, so SSH/WinRM has no login user. Guarded by checking CommConfig.User() == "".

Source

Thrown at builder/null/config.go:48

	}, raws...)
	if err != nil {
		return nil, err
	}

	var errs *packersdk.MultiError
	if es := c.CommConfig.Prepare(nil); len(es) > 0 {
		errs = packersdk.MultiErrorAppend(errs, es...)
	}

	if c.CommConfig.Type != "none" {
		if c.CommConfig.Host() == "" {
			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

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Set communicator.username (or user) to the SSH/WinRM account on the target host
  2. Use ssh_username for legacy JSON templates
  3. Set communicator = "none" if no connection is needed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at builder/null/config.go:48 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/f49ffc6869a83d54. Report an issue: GitHub.