# Typing password echoing in chrooted environment



## astperl (Jan 26, 2022)

I created chroot directory for SSH access. But after login, everything that requires password input (including mysql login) always echoing the password characters I typed. This is not a problem in host, only in chrooted environment. Please help how to turn off echo of the password.


----------



## astperl (Jan 26, 2022)

This is FreeBSD 13.0-RELEASE-p4

And sshd_config for Match User:


```
ChrootDirectory /vusr
X11Forwarding no
AllowAgentForwarding no
AllowTcpForwarding no
```


----------



## covacat (Jan 26, 2022)

most likely your input is not a tty
do you have a proper /dev in chroot ?
what is the output of 'tty'


----------



## astperl (Jan 26, 2022)

```
# ls /dev
null

# tty
/dev/pts/0
```


----------



## covacat (Jan 26, 2022)

try
stty -echo
if you lose echo blindly type 
stty sane


----------



## astperl (Jan 26, 2022)

I tried as follow (not real passwd):


```
# stty -echo
# mysql -u -p mysql
Enter password: @fo{k)@fk9
```

No changes, password still echoing.
Btw, the chroot was created with both `bsdinstall jail /vusr` and just simply SSH chroot. Both has same result. Password echoed.

Should /dev/ populated with tty* ?


----------



## covacat (Jan 26, 2022)

astperl said:


> Should /dev/ populated with tty* ?


i'm not sure, but try it
stty -echo should turn echo off immediately (for all shell input)


----------



## astperl (Jan 26, 2022)

I populated /dev/* with `mount -t devfs devfs /vusr/dev`

Now it has /dev/tty*

`# stty -echo`

Chroot into, and still password echoing.


----------



## covacat (Jan 26, 2022)

stty -echo does not work for me either in chroot but mysql -h host -p wont echo if i have a dev
without a /dev will echo

somehow stty line discipline is not passed to the parent process but works inside the proc which sets it
i tested with a hacked version of stty and indeed the echo is turned off until stty exits
then it's back to normal


----------



## astperl (Jan 26, 2022)

I think this only works if jail is running. I created the jail just for chroot with a complete FreeBSD dist, not for running jail itself and dont intend to run jail, that's where the problem occured i think. Long time ago when doing diskless, stty -echo works fine too.


----------



## kpedersen (Jan 26, 2022)

astperl said:


> I populated /dev/* with `mount -t devfs devfs /srv/dev`


Do you have /dev/pts?

pts is for pseudo ttys. I can't recall if mounting devfs includes that. Possibly SSH uses this.

What happens if you install and run tmux in the Jail / chroot? Can it run? Does the password still get echoed?


----------



## covacat (Jan 26, 2022)

the problem is easy to test/reproduce on any box
chroot /rescue /sh
./stty -echo
type something


----------



## astperl (Jan 26, 2022)

Yes `/dev/pts` is there. Inside jail (without jail runs)/chroot

Runs tmux:
`open terminal failed: can't use /dev/pts/0`


----------



## covacat (Jan 26, 2022)

in chroot (no jail) stty -echo fails in screen too


----------

