I've had problems with people logging into some servers via ssh and forgetting that a specific terminal is no longer local. Today someone tried to shutdown their laptop with sudo shutdown -h now, and accidentally took down a server.
I'd like to change the colour of bash's PS1 on these servers when logged in via ssh. I control these servers via a debian package that I push to them.
What's the best way to push a site-wide PS1 default?
The obvious answer is to create a file /etc/profile.d/sshcolours with this content to make the user@host purple:
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] ; then PS1='\[\033[01;35m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' fi bash will read that via /etc/profile (which sources /etc/profile.d/*). However, it will later read ~/.bashrc which will probably override PS1 based on $TERM as defined in /etc/skel/.bashrc.
Is there some way I can source my site-wide file after ~/.bashrc without touching ~/.bashrc and without forcing my team to adopt a client-side change?
Here are a couple of bad ideas:
After setting
$PS1,~/.bashrcconditionally sources/usr/share/bash-completion/completions/*, so I could put my file there. But some testing showed me that the condition isn't met, or/usr/share/bash-completion/bash_completionreverts the environment.In
postinstI could append a line to source my file to each user's~/.bashrc. This feels both illegal and buggy:
for h in /home/*; do if [ ! grep -q profile_amendments "$h/.bashrc" ] ; then echo ". /etc/profile_amendments" >> "$h/.bashrc" fi done 
/etc/sudoersisn't going to help. It's hard to choose a colour that will work for everyone without changing the client-side procedure./sbin/shutdownwith a script that prints something likeWARNING, $HOSTNAME WILL SHUT DOWN IN 30 SECONDS, sleep a bit and then run the actualsystemctlcommand.