Bobcares

pty allocation request failed on channel 0 – Lets’solve it!

by | Oct 8, 2019

Do you have trouble when logging into a server through ssh?

SSH errors are quite frustrating, especially when doing server changes at the last minute.

One such error is the pty allocation request failed on channel 0 error.

At Bobcares, we help server owners resolve SSH errors as part of our Server Management Services.

Today, let’s discuss the pty allocation request failed error and see how our Support Engineers fix it.

 

What is the pty allocation request failed on channel 0 error?

As the first step, let’s check the details of the error “pty allocation request failed on channel 0“.

It is one of the common errors that happen when we ssh into the server.

The error mainly occurs when the SSH server isn’t assigning a TTY instance for the connection. In simple words, this affects the interactivity in the shell.

This typically happens when SSH command has an alias set on the server.

One of our customers contacted us with a similar error. He was trying to connect to the server through ssh like this:

ssh  username@my-server.com -p 22

And, it gave the error message as:

PTY allocation request failed on channel 0
shell request failed on channel 0

 

How we fix the pty allocation error?

 

Now, we know the scenario that causes this pty allocation request failed error.

Let’s see the major causes and how our Support Engineers fix this error.

 

1. Incorrect Mount options

One of the top reasons for SSH channel error will be incorrect mount option set for /dev/pts.

The /dev/pts is a virtual filesystem in the kernel for the pseudo-terminal.  Usually, init scripts or daemons like systemd takes care of the proper mounting of the devpts filesystem. In general, there is a limit of 256 pseudo terminals on a system. And, when any application running on the server starts leaking pseudo terminals, SSH returns TY allocation failure.

Here, our Support Engineers first check and see what processes have open pseudo-terminals using:

lsof /dev/pts/*

And, fix the error by unmounting and remounting /dev/pts.

For this, we use the command:

$ umount /dev/pts
$ mount devpts /dev/pts -t devpts

And that resolves the error effectively.

In case, if the server becomes inaccessible, we suggest the customers reboot the server to single user mode and add these lines to your /etc/mtab & /etc/fstab entry.

To do this, we open the file /etc/mtab or /etc/fstab. Then after, we add the line into these files.

none /dev/pts devpts defaults 0 0

At last, we reboot the system to make the changes effective.

 

2. SSH settings

In a similar way, incorrect SSH settings can also trigger this error. For example, when the SSH binary is aliased to ‘ssh –t’ it can result in an error.

Additionally, the same error pops up when access to PTY is prohibited in .ssh/authorized_keys file.

Or when the SSH configuration file holds entries like “PermitTTY yes“, it can even cause the TTY error. Ultimately, this results in a failed login.

Therefore, we edit the configuration and set the entry as:

PermitTTY no

That fixes the problem and makes SSH working again.

[Need help to solve the pty allocation request failed on channel 0 error? We’ll help you.]

 

Conclusion

In short, the ssh pty allocation request failed on channel 0 error happens when the server isn’t assigning a TTY instance for the connection. Today’s write-up also discussed the reasons for this error and how our  Support Engineers fixed it for our customers.

2 Comments

  1. Jacqueline Modise

    Is it possible to come a member, is this a forum? kinldy advise

    Reply
    • Sijin George

      Hello Jacqueline,
      This is the Bobcares blog and not a forum. To read on the latest article simply bookmark the link https://bobcares.com/blog/

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF