LinuxQuestions.org
Latest LQ Deal: Linux Power User 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 11-20-2014, 04:27 AM   #1
rajmaniperumal
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, 06:21 AM   #2
bradvan
Member
 
Registered: Mar 2009
Posts: 235

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,
Code:
NAM=$(hostname -s)
NAM=${NAM:0:3}
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, 06:58 AM   #3
rajmaniperumal
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 xlpasrv01.abc.com
[abc@xlpeos01 ~]$

Thanks for your response

Last edited by rajmaniperumal; 11-20-2014 at 07:02 AM.
 
Old 11-20-2014, 08:08 AM   #4
bradvan
Member
 
Registered: Mar 2009
Posts: 235

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.
 
  


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


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