[Android Q&A, Help & Troubleshooting] E:V:A:
I have a rooted a GT-I9195 (SGS4-mini) done with CF-Auto-Root and the latest Busybox. I then decided to use the "Ssh server" from The Olive Tree, since it is simple, small, free, but unfortunately have ads. For on-device/local shell, I use the Android Terminal Emulator and everything works great, including su and shell environment.

However, I have a really strange bahaviour when connecting using ssh via WiFi, and trying to su.

First when connecting via ssh, I get the following message.

[SIZE=2]$ ssh -2 -4 -t sshu@192.168.1.10 -p 50555
Authenticated with partial success.
sshu@192.168.1.10's password:
/system/bin/sh: No controlling tty: open /dev/tty: No such device or address
/system/bin/sh: can't find tty fd
/system/bin/sh: warning: won't have full job control
sshu@android:/ $[/SIZE]

I have Googled this and there's little useful info. On one site they even say:

[SIZE=2]Getting a controlling tty

[B]How does one get a controlling terminal? [COLOR=Red]Nobody knows[/COLOR], this is a great mystery.[/B]

The System V approach is that the first tty opened by the process
becomes its controlling tty. The BSD approach is that one has to
explicitly call

ioctl(fd, TIOCSCTTY, ...);

to get a controlling tty.

Linux tries to be compatible with both, as always, and this results in
a very obscure complex of conditions. Roughly:

The [B]TIOCSCTTY [/B]ioctl will give us a controlling tty, provided that (i)
the current process is a session leader, and (ii) it does not yet have
a controlling tty, and (iii) maybe the tty should not already control
some other session; if it does it is an error if we aren't root, or we
steal the tty if we are all-powerful.

Opening some terminal will give us a controlling tty, provided that
(i) the current process is a session leader, and (ii) it does not yet
have a controlling tty, and (iii) the tty does not already control
some other session, and (iv) the open did not have the [B]O_NOCTTY[/B] flag,
and (v) the tty is not the foreground VT, and (vi) the tty is not the
console, and (vii) maybe the tty should not be master or slave pty.
[/SIZE]

Now this is not the end of the world, if it was not that it doesn't understand normal terminal control characters and in addition, when I do su, I loose the command prompt. However, using the "-i" (interactive) switch gets me the "#" prompt, but environment is still completely messed up:

[SIZE=2]sshu@android:/ $ [B]su -c /system/bin/sh -i[/B]
/system/bin/sh: No controlling tty: open /dev/tty: No such device or address
/system/bin/sh: can't find tty fd
/system/bin/sh: warning: won't have full job control
sshu@android:/ #[/SIZE]

I've never had or seen this issue before. Any ideas?

(Also, where would I put a source to my .bashrc and make sure it runs when su'ing or ssh?)

PS. The phone is using a stock 4.2.2 SELinux kernel.

[SIZE=2]Device: Samsung Galaxy S4 Mini LTE (GT-I9195)
Board/Platform: MSM8930AB (Snapdragon 400)
Baseband: I9195XXUBML4
Kernel: 3.4.0-2340422
se.infra@SEP-65 #1
Build: JDQ39.I9195XXUBML4
SE: SEPF_GT-I9195_4.2.2_0022
ro.build.date: Sat Dec 21 01:46:00 KST 2013
ro.build.description: serranoltexx-user 4.2.2 JDQ39 I9195XXUBML4
[/SIZE]