Skip to content
Latchkey

chmod: Usage, Options & Common CI Errors

chmod sets who can read, write, and execute a file.

chmod fixes two recurring CI problems: scripts that lost their execute bit (often after a checkout or download) and SSH keys that are too permissive for ssh to accept.

What it does

chmod changes the permission bits of files and directories, using either symbolic notation (u+x, go-w) or octal numbers (755, 600). The bits control read (4), write (2), and execute (1) for owner, group, and others.

Common usage

Terminal
chmod +x deploy.sh             # make executable
chmod 755 script.sh           # rwxr-xr-x
chmod 600 key.pem             # required for SSH private keys
chmod -R u+rwX,go-w ./dir     # recursive, X = dirs/already-exec
chmod 644 config.yaml

Options

ItemWhat it does
+x / u+xAdd execute (all / owner)
755 / 644 / 600rwxr-xr-x / rw-r--r-- / rw-------
-RRecurse into directories
X (capital)Execute only if a dir or already executable
ugoUser, group, others

Common errors in CI

"./deploy.sh: Permission denied" means the execute bit is missing - chmod +x it (Git can preserve the bit; downloads and some unzips do not). For SSH, "Permissions 0644 for key are too open" is fatal: chmod 600 the key. On Windows/WSL or certain mounted filesystems chmod is a no-op (mode tracked elsewhere), so the bit may not "stick". Prefer chmod -R ...,go-w over a blanket 777, which fails security scans.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →