Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-02-2015, 03:07 PM   #1
Registered: Apr 2012
Posts: 49

Rep: Reputation: Disabled
Change SSH font color in terminal?

Is there a way to change the font color, within my local terminal, every time I SSH into another machine?

I know I can set it up on each individual remote machine by adding something to my bashrc file. But, I ssh into 50 or so machines and would prefer not to ssh into each individual one. There may not be another way though?

Old 03-02-2015, 03:14 PM   #2
LQ Veteran
Registered: Jan 2011
Location: Yawnstown, Ohio
Distribution: Mojave
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Have a look at the PS1 values/settings

Last edited by Habitual; 03-02-2015 at 03:15 PM.
Old 03-02-2015, 03:24 PM   #3
Registered: Apr 2012
Posts: 49

Original Poster
Rep: Reputation: Disabled
So all I need is this code in my bashrc?

# User and server
local SSH_IP=`echo $SSH_CLIENT | awk '{ print $1 }'`
local SSH2_IP=`echo $SSH2_CLIENT | awk '{ print $1 }'`
if [ $SSH2_IP ] || [ $SSH_IP ] ; then
Old 03-02-2015, 03:44 PM   #4
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,405
Blog Entries: 11

Rep: Reputation: 3358Reputation: 3358Reputation: 3358Reputation: 3358Reputation: 3358Reputation: 3358Reputation: 3358Reputation: 3358Reputation: 3358Reputation: 3358Reputation: 3358
I don't think that is correct - you cannot (easily) do anything on the local machine that will change the prompt generated by the remote machine.

You must make the change in each ~/.bashrc on the remote machines.

I use something like this on all of my own:

#Make prompt colored when logged in remote
export NON_LOCAL_LOGIN=`env | grep SSH`
if [ "$NON_LOCAL_LOGIN" != "" ]; then
       PS1="\033[33m[\u@\h:\w]#\033[0m "
Just add that to the ~/.bashrc on each remote machine and you will be all set.

You don't need it until you login so no need to change them all at once - just keep the code snippet handy and when you login to a non-colored prompt add it to the .bashrc.
2 members found this post helpful.
Old 03-02-2015, 04:24 PM   #5
Registered: Apr 2012
Posts: 49

Original Poster
Rep: Reputation: Disabled
Thank you


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Putty terminal color change when ssh to remote server based on the environment rajmaniperumal Linux - Newbie 3 11-20-2014 08:08 AM
How to change font color and font size in terminal ? wlaw Linux - Newbie 3 05-15-2007 08:57 PM
change the font color Drunkalot Linux - General 2 08-09-2005 10:37 PM
Terminal font and color berkay Linux - Newbie 10 09-23-2004 02:19 AM
Changing Terminal background colour and font color dpbatagoda Linux - Newbie 0 12-05-2003 12:38 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:14 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration