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 11-20-2014, 05:27 AM   #1
LQ Newbie
Registered: Nov 2014
Posts: 2

Rep: Reputation: Disabled
Putty terminal color change when ssh to remote server based on the environment

Hi everyone, appreciate your help in advance.

We have centralized Linux admin server(GodBox). If we want to access other servers across the environment(ITEST/DEV/QA/PROD) first we need to login admin server from there we ssh to other environment.

this is what my requirement. when I ssh to QA or PROD servers putty session colour should change to Green/Red vice versa. We have many QA and Prod servers and i don't have list of them.

QA servers naming starts with xlq* and prod naming starts with xlp*. can we add script in bash_profile to acheive this.
Old 11-20-2014, 07:21 AM   #2
Registered: Mar 2009
Posts: 246

Rep: Reputation: 53
A quick google search for "setting color in linux prompt" gives several good examples. The first one, Color Bash Prompt - ArchWiki is very good. Proceed your prompt change with a test for the hostname. For example,
NAM=$(hostname -s)
if [[ ${NAM} = "xlq" ]]; then
put your prompt code for this site. Is this close to what you were after, or did I misunderstand?
Old 11-20-2014, 07:58 AM   #3
LQ Newbie
Registered: Nov 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
xlpasrv01 is admin server. xlpeos01 is prod server. (As I mentioned in earlier there are many servers QA - xlq* and Prod - xlp*)

I am ssh'ing xlpeos01 from admin server. prompt color should change to RED.

[abc@xlpasrv01 ~]$ ssh xlpeos01
abc@xlpeos01's password:
Last login: Wed Sep 10 00:59:04 2014 from
[abc@xlpeos01 ~]$

Thanks for your response

Last edited by rajmaniperumal; 11-20-2014 at 08:02 AM.
Old 11-20-2014, 09:08 AM   #4
Registered: Mar 2009
Posts: 246

Rep: Reputation: 53
OK, if I understand correctly, server A is always an admin server for example. It doesn't dynamically change roles? If so, go on each server and set it's prompt to the appropriate color. Then every time anyone logs in to that server, the prompt will be the appropriate color.


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
Help with Ubuntu server remote ssh and local network ssh issues using putty. scottpops Linux - Server 8 05-17-2012 06:07 PM
[SOLVED] putty ssh works but ssh from terminal does not felixtheratruns Linux - Server 6 04-29-2010 01:01 PM
LXer: Key-Based SSH Logins With PuTTY LXer Syndicated Linux News 1 12-10-2006 12:21 PM
Color depth of remote terminal BrainScanning Linux - Networking 2 09-14-2005 12:10 AM
Problem with remote terminal (ssh and PuTTY) guardian653 *BSD 11 02-09-2005 07:16 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:32 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