SSH "PTY allocation request failed on channel 0"
What the PTY allocation message means, why a host refuses a terminal, and how the -t, -T and RequestTTY options change the result.
An interactive SSH session needs a pseudo-terminal (pty) on the host. The client asks for one at the start of the session. If the host says no, OpenSSH prints:
PTY allocation request failed on channel 0
This means the host refused the request. The login itself worked.
What happens next
- If you did not insist on a terminal, the session carries on without one. Commands that need a terminal, such as full-screen programs and sudo prompts, then fail or look wrong.
- If you did insist, the failure is fatal and the session closes. You insist with
ssh -t, or withRequestTTY yesorRequestTTY forcein~/.ssh/config.
Why a host refuses
On the host, check these in order:
PermitTTY noinsshd_config. The setting controls whether pty allocation is allowed. The default isyes. It can be set inside aMatchblock, so it may apply only to some users or addresses.no-ptyorrestricton the key. In the user'sauthorized_keys, the optionno-ptyprevents tty allocation, and a request to allocate a pty will fail.restrictturns on all restrictions, including no pty. These are usually set on keys made for one task, such as the remote backups that sshd(8) gives as an example forcommand=.- A host fault. If none of the above is set, the administrator should look at the SSH service's log for the cause.
If the account is meant to be a login account, ask the administrator to remove the restriction. If it is a restricted account, you cannot get a shell with that key. A different symptom of a login-disabled account is that SSH authenticates, then prints This account is currently not available. and closes; see SSH "This account is currently not available" (nologin shell).
The other direction: no terminal requested
Commands you run through ssh host command do not get a terminal unless you ask for one. If you ask with -t but your own input is not a terminal, for example a script, ssh prints "Pseudo-terminal will not be allocated because stdin is not a terminal." Use -tt to force one.
-t: Request a terminal.-tt: Force a terminal, even if ssh has no local terminal.-T: Never request a terminal. Use this for binary data or scripts.RequestTTY auto: A terminal is requested when opening a login session.
Related
- Authorized keys and permissions
- SSH: how it works
- SSH problems
- Shell and tmux basics
- SSH error messages, what each one means
- SSH "This account is currently not available" (nologin shell)
- sudo "a terminal is required to read the password" when running a command over SSH
- tmux "open terminal failed: not a terminal" and bash "no job control in this shell" over SSH