I'm trying to resolve an SSH connection issue on an Android phone running SELinux
in "Enforcing" mode. The problem is that any SSH connection that tries to allocate a pseudo-terminal (/dev/pts
etc) is denied permission, leaving my connection without a controlling tty. Practically this means that I loose the ability to use normal terminal control for editing, command history, CTRL characters etc.
Presumably this means that SELinux is preventing the SSH daemon from opening /dev/ptmx
.
I have no idea how to remedy this highly annoying situation, from within SSH server device (phone).
I'm running SSHelper on a non-priviledged port 2222 on a Samsung S4 using an SELinux Enforcing AOS 4.2.2 version. The weirdest thing is that I have root access using su under "Enforcing", but when I disable "Enforcing" and go to "Permissive", everything works in terminal, but I can no longer use su to gain root! (Simply no reaction and no error message.)
So there must be a way to control this under SELinux, but where and how?
Or is this a triviality and that I have only missed something?
For SSH connection in Enforcing mode, I use:
$ ssh -2 [email protected] -p 2222
SSHelper Version 6.3 Copyright 2014, P. Lutus
[email protected]'s password:
PTY allocation request failed on channel 0
Linux 3.4.0-2340422 armv7l
This gets me a non tty shell with no prompt, severely limiting any editing possibilities.
PS. I have already tried with ssh -t ...
, no go.
/dev/ptmx
is how the SSH server creates a terminal, and that's presumably what SELinux is restricting. I don't know how to change the SEAndroid policy — I presume that it's made purposefully difficult, since smartphone manufacturers tend to dislike allowing users to control the device that they supposedly own. @mirabilos/dev/pts
mounted wrong by default. The fix involve opening 2 terminals at once and re-mounting /dev/pts with the right permissions.