I’ve been running a VPS since 2013 and it recently got migrated to a new provider since the company I rented the VPS from got acquired by another company.
Since this migration, I was unable to SSH into my server because of the PTY allocation request failed error. The server did not get a TTY or Interactive shell as most of you call it.
The first step to login by forcing a TTY is fairly simple:
$ ssh user@host "/bin/bash -i"
But when running any command as root or when becoming root, it throws an error that sudo requires TTY.. aargghh. Ok. This is because the /etc/sudoers file states requiretty. You can safely remove this line since it adds no security benefit. Even RHEL and Fedora distributions have removed this from their recent releases.
Now I was able to execute commands with sudo, I’d found out that the /dev/pts was not mounted. This is a common root cause for the PTY allocation request failed error. When I mounted /dev/pts again using
$ sudo mount devpts /dev/pts -t devptsI
I was able to login using ssh without forcing a TTY.
Let me know on Twitter if this solved your problem.