Skip to content
Latchkey

chmod Command Reference for CI Scripts

chmod sets the read, write, and execute permission bits on files and directories.

chmod shows up in CI mainly to make scripts executable and to lock down private keys. SSH refuses to use an over-permissive key, so chmod 600 is a common fix.

Common flags/usage

  • +x: add the execute bit (chmod +x script.sh)
  • 600 / 644 / 755: octal user/group/other permission triples
  • -R: apply recursively to a directory tree
  • u+x / go-w: symbolic mode (add/remove for user/group/other)
  • --reference=FILE: copy another file\u2019s mode

Example

shell
chmod +x scripts/deploy.sh
install -m 600 /dev/stdin "${HOME}/.ssh/id_ed25519" <<< "${SSH_KEY}"
chmod 600 "${HOME}/.ssh/id_ed25519"

In CI

SSH and many tools refuse a key with "Permissions 0644 are too open" until you chmod 600 it. A "Permission denied" running a checked-out script usually means the execute bit was lost; chmod +x it. Note that git tracks only the execute bit, so other mode changes do not survive a checkout.

Key takeaways

  • chmod 600 a private key or ssh rejects it as too open.
  • chmod +x restores the execute bit lost on some checkouts.
  • git only tracks the execute bit, so other mode changes are not preserved.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →