This SSH error occurs when the server cannot allocate a pseudo-terminal (PTY) for your session. It typically appears with git operations, SFTP transfers, or interactive SSH connections and is usually non-fatal but indicates the server rejected TTY allocation.
A PTY (pseudo-terminal) is a virtual terminal interface that enables interactive SSH sessions. When SSH shows 'PTY allocation request failed on channel 0', it means the SSH server received a request to create an interactive terminal session but was unable or unwilling to allocate one. The server may have run out of available PTYs, have incorrect filesystem mounting, or be configured to reject interactive sessions. Depending on your use case, this may be a warning that doesn't prevent the command from completing, or it may indicate a genuine connection problem.
If you're performing a non-interactive operation (like git clone, file transfer, or running a remote command), the PTY allocation warning may be harmless. Try suppressing the TTY request:
ssh -T user@hostname command
git clone --depth 1 ssh://[email protected]/user/repo.gitThe -T flag tells SSH not to allocate a pseudo-terminal, which is appropriate for non-interactive sessions. If the command completes successfully, the original error was just a warning.
If you have console or root access to the problematic server, verify that /dev/pts is properly mounted:
mount | grep ptsYou should see output like: devpts on /dev/pts type devpts (rw,nosuid,noexec,...)
If the output is missing or shows incorrect options, remount it:
sudo umount /dev/pts
sudo mount -t devpts devpts /dev/ptsVerify again with mount | grep pts. The mount should now show proper devpts mounting.
Check the SSH server configuration file for PTY-related settings:
sudo grep -i permitty /etc/ssh/sshd_configThe output should show PermitTTY yes (the default). If it shows PermitTTY no or the line is missing, edit the config:
sudo nano /etc/ssh/sshd_configLook for the PermitTTY line and ensure it is set to yes, or add it if missing:
PermitTTY yesSave the file and reload SSH:
sudo systemctl reload ssh
# or on some systems:
sudo systemctl reload sshdIf the server is experiencing many open SSH sessions, it may have run out of available pseudo-terminals. Check current PTY usage:
ls /dev/pts/ | wc -lThis shows how many PTY sessions are currently allocated. Linux systems typically support up to 256. If you're near or at the limit, identify and kill idle sessions:
# List all process trees with TTY
ps aux | grep sshd
# Kill idle SSH sessions (use with caution)
ssh user@hostname pkill -f 'sshd:.*@pts'If PTY exhaustion is chronic, investigate applications that may be leaving PTY handles open without closing them.
If the SSH server uses chroot jails (common in restricted setups), ensure the chroot environment has proper device filesystem access:
sudo ls -la /var/chroot/user/dev/pts 2>/dev/nullIf the directory doesn't exist or has wrong permissions, create it:
sudo mkdir -p /var/chroot/user/dev/pts
sudo chmod 755 /var/chroot/user/dev/ptsVerify your sshd_config has the chroot directive:
sudo grep -i chrootdirectory /etc/ssh/sshd_configThen reload SSH:
sudo systemctl reload sshdSome servers, containers, or appliances deliberately don't support interactive SSH sessions. If commands still work with ssh -T or direct commands, the restriction is intentional. To get an interactive shell:
- For Docker containers: Use docker exec -it container_name bash instead
- For Kubernetes pods: Use kubectl exec -it pod_name -- /bin/bash
- For cloud VMs: Use the cloud provider's web console or serial console
- For appliances: Check documentation for provided management interfaces
If you absolutely need interactive SSH on a container or appliance, consult the provider's documentation for supported access methods.
PTY allocation requests happen transparently when you use ssh hostname for an interactive login. However, the request can fail gracefully if the server doesn't support TTY sessions. Many services (like GitHub's git operations) don't require an interactive TTY and run fine with -T. The error is often cosmetic but can indicate systemic issues like filesystem mounting problems or resource exhaustion. In systemd systems, /dev/pts is usually managed automatically by devtmpfs and systemd-logind, so manual mounting is rarely needed on modern distributions. On AIX systems, the limit of available PTYs can be checked with lsattr -l pty0. Containers and sandboxed environments may intentionally disable PTY allocation for security reasons—this is not a bug but a feature of that environment. If you're administering a production system and seeing frequent PTY allocation failures, check dmesg or systemd journal for underlying errors that may indicate filesystem or kernel issues.
Load key "/home/user/.ssh/id_rsa": invalid format
How to fix 'Load key invalid format' in SSH
Bad owner or permissions on /home/user/.ssh/config
How to fix "Bad owner or permissions on .ssh/config" in SSH
Error connecting to agent: Connection refused
How to fix "Error connecting to agent: Connection refused" in SSH
Connection closed by UNKNOWN port 65535
How to fix 'Connection closed by UNKNOWN port 65535' in SSH
Offending ECDSA key in /home/user/.ssh/known_hosts:line
How to fix "Offending ECDSA key in known_hosts" in SSH