ssh -t and -T: Pseudo-Terminal Control
ssh -t requests a pseudo-terminal for the remote session; -T disables one.
Most CI commands need no TTY, but a few remote tools insist on one. Knowing which flag to use avoids both broken interactive tools and noisy warnings.
What it does
A pseudo-terminal (PTY) makes the remote process behave as if attached to a terminal. ssh allocates one automatically for interactive sessions but not when you pass a command. -t forces one anyway; -t -t forces it even without a local TTY; -T disables allocation.
Common usage
# force a PTY for a remote tool that needs one (e.g. sudo with a prompt)
ssh -tt user@host "sudo systemctl restart app"
# explicitly disable a PTY to silence the warning
ssh -T user@host "deploy.sh"Options
| Flag | What it does |
|---|---|
| -t | Request a PTY (still needs a local TTY) |
| -tt | Force PTY allocation even without a local TTY |
| -T | Disable PTY allocation |
| -o RequestTTY=force|no | Same control via an option |
In CI
Default to -T or no flag for scripted commands; CI has no terminal, so requesting a PTY just emits a warning. Reach for -tt only when a remote tool genuinely requires a TTY, such as a sudo password prompt or a program that refuses to run otherwise.
Common errors in CI
Pseudo-terminal will not be allocated because stdin is not a terminal. appears when -t is used but the runner has no TTY; use -tt to force one or -T to disable. With a forced PTY, remote output may include carriage returns that clutter logs. "sudo: a terminal is required to read the password" is the opposite case: add -tt so sudo can prompt.