“PTY allocation request failed on channel 0 stdin: is not a tty” when SSH'ing into a Debian server
So, /dev/pts
is a virtual filesystem in the kernel for the p
seudo t
erminal s
(omething; not sure what the s stands for). It is a virtual kernel-only filesystem that exports some data from the kernel, very much like sysfs
(/sys) and procfs
(/proc) do as well. The filesystem should be mounted with a type devpts
, on /dev/pts
.
This is a special filesystem that doesn't usually appear in /etc/fstab
, but it needs to be mounted. Usually distributions have init scripts or similar to do the mounts needed; but occasionally this may fail, and then you get issues like that.
On systemd-based systems, this problem should not occur anymore; systemd takes care of ensuring that the devpts
filesystem is mounted.
If you use a different init system, then the fix may depend on the distribution you use. On Debian with sysvinit
, the devpts
filesystem is mounted by the mountdevsubfs.sh
init script. If you run into this problem ever again, you can do one of two things:
- Run
/etc/init.d/mountdevsubfs.sh restart
- Bypass the init script and manually run
mount -t devpts devpts /dev/pts
Related videos on Youtube
Erwin Rooijakkers
Updated on September 18, 2022Comments
-
Erwin Rooijakkers over 1 year
My hosting space (Debian Wheezy) serves two websites (one WordPress and one Rails). Today I saw both were down and I rebooted the server. The Rails site works again and the WordPress one now says that it has an error connecting to the database. Then after the reboot (from SSH as well) I SSH'ed into the server I got the following message:
PTY allocation request failed on channel 0 stdin: is not a tty
When I run with
-v
flag I get output with nothing strange I think (just checking the public and private key). See this gist.When I SSH as follows
ssh user@host "/bin/bash -i"
I can login into the remote shell.I read in another answer (which also provided also the tip with appending "bin/bash -i" and that helped) that I should manually remove and re-add the
/dev/pt*
files. The one who asked the question said that unmounting/dev/pts
and remounting it worked. Unfortunately I get the error:Can't find /dev/pts in /etc/fstab or /etc/mtab
My
/etc/fstab
files looks like this:#UNCONFIGURED FSTAB FOR BASE SYSTEM
Does anyone have any idea what is going on and how I can solve this?
Output of
tty; ls -l /proc/self/fd
locally:/dev/pts/2 total 0 lrwx------ 1 erwin erwin 64 Sep 13 19:01 0 -> /dev/pts/2 lrwx------ 1 erwin erwin 64 Sep 13 19:01 1 -> /dev/pts/2 lrwx------ 1 erwin erwin 64 Sep 13 19:01 2 -> /dev/pts/2 lr-x------ 1 erwin erwin 64 Sep 13 19:01 3 -> /proc/4389/fd
Output of
ls -la /dev/ptmx /dev/pts
on remote machine:crw-rw-rw- 1 root tty 5, 2 Sep 11 00:19 /dev/ptmx /dev/pts: total 8 drwxr-xr-x 2 root root 4096 Mar 10 2013 . drwxr-xr-x 3 root root 4096 Sep 11 00:35 ..
Login via
ssh root@host "/bin/bash -i"
at 18:10 and looked in/var/log
. Besides a cronjob I saw one file that was edited:-rw-r----- 1 root adm 614306 Sep 15 18:10 auth.log
and syslog (via cronjob). Syslog was a coincidence since something happened every 30 minutes which relates to PHP.
Then I copied the file via
scp
to local.auth.log:
Sep 15 18:10:23 vz1223 sshd[23681]: Accepted publickey for root from [localIp] port 39126 ssh2 Sep 15 18:10:23 vz1223 sshd[23681]: pam_unix(sshd:session): session opened for user root by (uid=0) Sep 15 18:12:14 vz1223 sshd[23681]: Received disconnect from [localIp]: 11: disconnected by user Sep 15 18:12:14 vz1223 sshd[23681]: pam_unix(sshd:session): session closed for user root Sep 15 18:12:29 vz1223 sshd[23700]: Accepted publickey for root from [localIp] port 39160 ssh2 Sep 15 18:12:29 vz1223 sshd[23700]: pam_unix(sshd:session): session opened for user root by (uid=0) Sep 15 18:12:29 vz1223 sshd[23700]: Received disconnect from [localIP]: 11: disconnected by user Sep 15 18:12:29 vz1223 sshd[23700]: pam_unix(sshd:session): session closed for user root Sep 15 18:12:47 vz1223 sshd[23709]: Accepted publickey for root from [localIp] port 39163 ssh2 Sep 15 18:12:47 vz1223 sshd[23709]: pam_unix(sshd:session): session opened for user root by (uid=0)
As said, according to this answer to a similar question I should
umount
andmount
my/dev/pts
by runningmount -t devpts -o OPTIONS devpts /dev/pts
.When I run
mount
I do not see/dev/pts
/ And when I runmount /dev/pts/
I get:can't find /dev/pts in /etc/fstab or /etc/mtab
. The output ofmount
is the following:/home/vz/private/1223 on / type simfs (rw,relatime)<br> proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)<br> sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)<br> tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=6556k,mode=755)<br> tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)<br> tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=39320k)<br>
Perhaps I should get
/dev/pts
to mount again?More logging with running
ssh -vvv user@host
gives this.result of
namei -lx /dev/pts
on host:f: /dev/pts Drwxr-xr-x root root / drwxr-xr-x root root dev drwxr-xr-x root root pts
*/edit 6/ I rebooted the server once again from SSH with the "
/bin/bash -i
" appended via thereboot
command and now the terminal is back to normal... I have no idea what went wrong nor what solved it, but it works again.-
Gilles 'SO- stop being evil' over 9 yearsAre you running these SSH sessions from a terminal? Post the output of
tty; ls -l /proc/self/fd
on the local machine, and ofls -la /dev/ptmx /dev/pts
on the remote machine. By the way, it's normal that/dev/pts
wouldn't be mentioned in/etc/fstab
, most distributions hard-code it in startup scripts. -
Gilles 'SO- stop being evil' over 9 yearsDoes anything appear in a log file? Check all files in
/var/log
that got modified at the time of the login attempt and post all messages generated at that time (replace host names by placeholders for privacy). -
Erwin Rooijakkers over 9 years@Gilles Nothing appears in
/var/log
except a change toauth.log
. I added this. -
garethTheRed over 9 yearsYou can run
ssh
with more than one-v
for increased logging:ssh -vvv ...
-
Erwin Rooijakkers over 9 years@garethTheRed Added the output.
-
garethTheRed over 9 yearsHmmm. I didn't say it would help though :-( Can you paste the output of
namei -lx /dev/pts*
please. -
Erwin Rooijakkers over 9 years@garethTheRed Haha np thank you. I pasted the result into the question.
-
Erwin Rooijakkers over 9 yearsOkay... I rebooted the server once again and now the terminal works again.
-
garethTheRed over 9 yearsFrom the last edit, your
dev
filesystem hadn't mounted for some reason. -
Admin over 9 yearsAre you chrooting?
-
garethTheRed over 9 yearsOn a running Debian system the
/dev
directory is atmpfs
mounted filesystem. Within that mount,/dev/pts
is adevpts
mounted filesystem. Thenamei -lx <full path>
command displaysd
for directories andD
for mount points for as the first character of each line. Your results showed/
as a mount point (D
) and the other two as mere sub-directories (d
). That suggests that they hadn't been mounted as/dev
and/dev/pts
. As it's working now, running that command again should showD
s. -
Adam Katz over 9 yearsI presume you've tried
ssh -t ...
("force pseudo-tty allocation") but it hasn't been noted anywhere. If that doesn't work, tryssh -tt ...
("force tty allocation even if ssh has no local tty").
-