Change terminal color in Ubuntu for SSH sessions
Well I made the mistake of leaving an SSH session logged in at home and then when I came back to my laptop to shut it down I typed "sudo halt" and then realised I was still on the server and everyone who was accessing the server was kicked off.
Not so much fun and a bit of a ammeter mistake, my solution was to change the colour of my terminal login prompt when in a ssh session. I tend to ssh into my home server quite a lot so I have an alias in my .bashrc file. Your .bashrc file is run when you login.
Here is the one line that you need to add to your ~/.bashrc file using your favourite editor, either gedit, nano or vi will do the trick.
alias home="tput setaf 1; ssh -X -p 675 -i ~/home.key [email protected]; tput setaf 0"
tput changes the prompt text colour, 1 = red and 0 = black. The other stuff is all to do with ssh, the -p is used to specify a custom port and the -i allows me to specify the location of my pgp key.
Unless you logout and back in the alias won't work. Your other option is to simply source the file with the following command.
source .bashrc
Comments
Couldn't find such a simpleā¦
Couldn't find such a simple solution on stackoveflow even ! Thanks man
Add new comment