Strovent SystemsSign in
Reference

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 with RequestTTY yes or RequestTTY force in ~/.ssh/config.

Why a host refuses

On the host, check these in order:

  1. PermitTTY no in sshd_config. The setting controls whether pty allocation is allowed. The default is yes. It can be set inside a Match block, so it may apply only to some users or addresses.
  2. no-pty or restrict on the key. In the user's authorized_keys, the option no-pty prevents tty allocation, and a request to allocate a pty will fail. restrict turns 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 for command=.
  3. 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.

Sources

Spotted a mistake? Email [email protected].