LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-02-2015, 04:07 PM   #1
bluforce
Member
 
Registered: Apr 2012
Posts: 39

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


Guys,
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?

TIA!
 
Old 03-02-2015, 04:14 PM   #2
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,167
Blog Entries: 10

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

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

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

Quote:
# 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
PS1+="(\[${RED}\]\u@\h"
else
PS1+="(\[${RED}\]\u"
fi
 
Old 03-02-2015, 04:44 PM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 3,880
Blog Entries: 1

Rep: Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998Reputation: 1998
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:

Code:
#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 "
fi;
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, 05:24 PM   #5
bluforce
Member
 
Registered: Apr 2012
Posts: 39

Original Poster
Rep: Reputation: Disabled
Thank you
 
  


Reply


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 09:08 AM
How to change font color and font size in terminal ? wlaw Linux - Newbie 3 05-15-2007 09:57 PM
change the font color Drunkalot Linux - General 2 08-09-2005 11:37 PM
Terminal font and color berkay Linux - Newbie 10 09-23-2004 03:19 AM
Changing Terminal background colour and font color dpbatagoda Linux - Newbie 0 12-05-2003 01:38 AM


All times are GMT -5. The time now is 10:40 AM.

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