I would like to disable TTY echoing for all users that are connecting via SSH. The Linux command stty -echo does the trick, however instead of users having to execute this command on their TTY I would like to give them a TTY that by default has echoing disabled from the start. how can I achieve this? thanks in advance!
- 4To give a meaningful answer, it would be helpful to know what these users are doing on the system and why you want to force this setting. TTY echo is normally managed by whatever program is running at the time. If your users are running some program that needs echo to be turned off, the program would normally do that.Kenster– Kenster2022-04-20 01:51:53 +00:00Commented Apr 20, 2022 at 1:51
1 Answer
One simple way is to add the line stty -echo to a file in /etc/profile.d where the filename ends in .sh. For example, a file named /etc/profile.d/disable-tty-echo.sh.
This works because, at least on Ubuntu, each /etc/profile.d/*.sh file will be sourced by /etc/profile, and the latter file will be read and executed (along with $HOME/.profile) by any POSIX login shell. This is documented in the man pages for bash, dash, ksh, etc.
Do note that if users are able to set their shell to one that does not read and execute /etc/profile, such as csh, and you need to be absolutely sure that stty -echo will be set, then you will also need to restrict the allowed login shells by editing /etc/shells.
- great answer, exactly what I needed, this worked on alpine linux, I ended up putting the command
stty -echo echonlinto/etc/profile.d/disable-tty-echo.shand I can confirm that it works as expected, thanksEvyatar Saias– Evyatar Saias2022-04-20 18:07:25 +00:00Commented Apr 20, 2022 at 18:07