PTY allocation request failed on channel 0

Recently I tried to ssh into a guest in vmware. I was able to authenticate in the server and I was not able to access the console. I was getting the following error.

$ ssh x.x.x.x
The authenticity of host ‘x.x.x.x (x.x.x.x)’ can’t be established.
RSA key fingerprint is 1c:4d:1b:6g:d5:40:db:5b:46:7f:bb:17:b1:1b:41:80.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘x.x.x.x’ (RSA) to the list of known hosts.
root@x.x.x.x’s password:
PTY allocation request failed on channel 0

On checking the logs from the console, I found the following error.

sshd[2641]: pam_unix(sshd:session): session opened for user root by (uid=0)
sshd[2641]: error: openpty: No such file or directory
sshd[2641]: error: session_pty_req: session 0 alloc failed
sshd[2756]: pam_unix(sshd:session): session opened for user root by (uid=0)
sshd[2756]: error: openpty: No such file or directory
sshd[2756]: error: session_pty_req: session 0 alloc failed

I found that the device file ptmx was missing the server. Now I have to recreate the device file. I googled around for sometime and found the following solution.

$ sbin/MAKEDEV -d /dev ptmx

And it worked. I restarted SSH service and was able to login to the vmware guest. 🙂

Fix ssh from WHM

If you are unable to login to cpanel server using ssh, the following script resets the SSH service configuration to the default one.

Substitute the server IP where required and take this in the web browser.

http://your_server_ip:2086/scripts2/doautofixer?autofix=safesshrestart

You will be able to login using SSH now 🙂