LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 10-16-2007, 06:01 PM   #1
bkone
Member
 
Registered: Jun 2006
Distribution: SUSE, Red Hat, Oracle Linux, CentOS
Posts: 108

Rep: Reputation: 15
ssh session


When you are in a ssh session how can you tell if in fact you are using ssh? Is there a way to tell the difference? Different prompt or something?
 
Old 10-16-2007, 06:27 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
There's some variable's set starting with SSH_. Execute for example this in a Bash shell:
Code:
[ -z "${SSH_CONNECTION}" ] && echo "NOT using ssh."
Could mod /etc/bashrc to make the prompt include a visual marker, not that hard.
 
Old 10-17-2007, 11:29 AM   #3
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,215
Blog Entries: 2

Rep: Reputation: 49
It's a good idea to have different coloured prompts for different boxes, you brought it up:

PS1="\[\033[1;35m\]\u@\h:\[\033[0m\]\[\033[1;34m\]\w\[\033[0m\]\[\033[1;35m\]$\[\033[0m\] "
Change 1;35 and 1;34 to vary the colours. For example put: PS1="\[\033[1;33m\]\u@\h:\[\033[0m\]\[\033[1;34m\]\w\[\033[0m\]\[\033[1;33m\]$\[\033[0m\] " on the other computer.
 
Old 10-17-2007, 03:34 PM   #4
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
Going along with lugoteehalt's suggestion, I often have the box name in my prompts.

For example, at home I have the following prompt (which I am likely to migrate to my work environment):

__[user@computer pwd]__
$
 
  


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
Killing an SSH Session chatmasta Linux - Networking 5 05-27-2015 03:51 AM
show ssh session ufmale Linux - Newbie 1 07-31-2007 02:08 PM
ssh -> perl -> spawn background proces hangs ssh session rhoekstra Programming 2 04-25-2006 02:05 AM
How to run a program in an ssh session that will run after you close out the session? dr_zayus69 Linux - Networking 5 03-05-2006 08:15 PM
persistent ssh session apepost Linux - Networking 4 11-12-2005 01:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:37 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
Open Source Consulting | Domain Registration