hashicorp/packer · error
Error chmodding script file to 0755 in remote machine: %s
Error message
Error chmodding script file to 0755 in remote machine: %s
What it means
After uploading the script, the provisioner runs `chmod 0755 <RemotePath>` on the remote host via comm.Start. If the communicator cannot start that command (connection lost, shell unavailable, command channel error), the retryable function returns this wrapped error. Note this only fires on failure to START the chmod command, not on a non-zero chmod exit status, which is ignored.
Source
Thrown at provisioner/shell/provisioner.go:342
err = retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error {
if _, err := f.Seek(0, 0); err != nil {
return err
}
var r io.Reader = f
if !p.config.Binary {
r = &UnixReader{Reader: r}
}
if err := comm.Upload(p.config.RemotePath, r, nil); err != nil {
return fmt.Errorf("Error uploading script: %s", err)
}
cmd = &packersdk.RemoteCmd{
Command: fmt.Sprintf("chmod 0755 %s", p.config.RemotePath),
}
if err := comm.Start(ctx, cmd); err != nil {
return fmt.Errorf(
"Error chmodding script file to 0755 in remote "+
"machine: %s", err)
}
cmd.Wait()
cmd = &packersdk.RemoteCmd{Command: command}
return cmd.RunWithUi(ctx, comm, ui)
})
if err != nil {
return err
}
// If the exit code indicates a remote disconnect, fail unless
// we were expecting it.
if cmd.ExitStatus() == packersdk.CmdDisconnect {
if !p.config.ExpectDisconnect {
return fmt.Errorf("Script disconnected unexpectedly. " +View on GitHub (pinned to eb36e3c3e4)
Solutions
- Increase start_retry_timeout so the built-in retry can ride out transient disconnects
- Verify the remote host's SSH/WinRM service is stable (no rebooting mid-provision)
- Check sshd MaxSessions/MaxStartups limits if parallel provisioners are used
- Re-run the build after confirming the machine is not restarting during provisioning
Example fix
// before
provisioner "shell" {
start_retry_timeout = "5m"
}
// after
provisioner "shell" {
start_retry_timeout = "15m"
} Defensive patterns
Strategy: retry
Try / catch
err = retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error {
// upload, then:
if err := comm.Start(ctx, chmodCmd); err != nil {
return fmt.Errorf("Error chmodding script file to 0755 in remote machine: %s", err)
}
return nil
}) Prevention
- Keep start_retry_timeout generous enough to absorb transient disconnects
- Ensure no other step reboots the machine between upload and execution
- Check sshd MaxSessions/MaxStartups when running parallel provisioners
- Confirm the guest's shell service (sshd/WinRM) is stable during provisioning
When it happens
Trigger: comm.Start(ctx, cmd) failing while running the chmod command inside the upload/retry block — typically a dropped SSH/WinRM session, or a communicator that cannot spawn a shell at that moment (e.g. machine mid-reboot).
Common situations: The instance restarted between upload and chmod so the SSH session died; sshd hit MaxSessions/connection limits; WinRM shell quota exhausted; transient network drops on long-running builds.
Related errors
- Error uploading script: %s
- Error removing temporary script at %s: %s
- failed to run OS detection command: %s
- failed to start scanner: %s
- Error chmodding script file to 0600 in remote machine: %s
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/80b31dc2b58c78df.
Report an issue: GitHub.