View previous topic :: View next topic |
Author |
Message |
RedBeard0531 Guru
Joined: 21 Sep 2002 Posts: 415 Location: maryland
|
Posted: Fri Jun 27, 2003 11:51 am Post subject: How to prevent forgeting you're SSH'ed |
|
|
Ive seen several posts talking about how people forget there on a box several thousand miles away, when they do something like mkfs, or shutdown -5. While I use this on my computer downstaris, it is still annoying it I do anything stupid, becuase it holds my media.
In /ets/profile, change this number in your PS1 variable to something differant on each machine.
PS1="\\[\\033[01;31m\\]\\h \\[\\033[01;34m\\]\\W \\\$ \\[\\033[00m\\]"
This will cause the hostname to appear a differant color. Here is a partial list of colors, if you want more, try them out.
29=grey
30=white
31=red
32=green
33=yellow
34=blue _________________ OH MY GOD! Kenny just killed Kenny!
That Basterd!
Last edited by RedBeard0531 on Fri Jun 27, 2003 8:54 pm; edited 1 time in total |
|
Back to top |
|
|
GenKiller n00b
Joined: 04 Mar 2003 Posts: 66 Location: United States of America
|
Posted: Fri Jun 27, 2003 8:08 pm Post subject: |
|
|
Are all those "B's" in your title really necessary? Or was that a typo?
This is a good tip, but perhaps this could be expanded into just changing the PS1 variable when someone ssh's in, and only then. That way, people could keep their current setup when they were physically at the machine (root=red user=green), and have it change when they are SSH'd in.
Just a thought, I don't know off the top of my head how to impliment it. _________________ http://www.digital-drip.com |
|
Back to top |
|
|
RedBeard0531 Guru
Joined: 21 Sep 2002 Posts: 415 Location: maryland
|
Posted: Fri Jun 27, 2003 8:55 pm Post subject: |
|
|
GenKiller wrote: | Are all those "B's" in your title really necessary? Or was that a typo? |
Im missing the nubby thing covering the mouse on my lappy, so Im always resting on the b botton. Thnx for pointen that out. _________________ OH MY GOD! Kenny just killed Kenny!
That Basterd! |
|
Back to top |
|
|
GenKiller n00b
Joined: 04 Mar 2003 Posts: 66 Location: United States of America
|
Posted: Fri Jun 27, 2003 10:58 pm Post subject: |
|
|
RedBeard0531 wrote: | Im missing the nubby thing covering the mouse on my lappy, so Im always resting on the b b[u]tton. Thnx for point[ing] that out. |
I thought it was probably something like that I can't begin to tell you how many programming typos I make because of similar reasons _________________ http://www.digital-drip.com |
|
Back to top |
|
|
cleber n00b
Joined: 05 Aug 2003 Posts: 74 Location: São Paulo - Brazil
|
Posted: Tue Aug 05, 2003 7:40 am Post subject: How to prevent forgeting you're SSH'ed |
|
|
I have a similar problem, so I got this .bashrc that helps me out.
Place this code inside your ~/.bashrc in every machine you have a login.
It changes $PS1if I'm on SSH (or telner, etc).
Code: |
#In ~/.bashrc
THIS_TTY=tty`ps aux | grep $$ | grep bash | awk '{ print $7 }'`
SESS_SRC=`who | grep $THIS_TTY | awk '{ print $6 }'`
SSH_FLAG=0
SSH_IP=`echo $SSH_CLIENT | awk '{ print $1 }'`
if [ $SSH_IP ] ; then
SSH_FLAG=1
fi
SSH2_IP=`echo $SSH2_CLIENT | awk '{ print $1 }'`
if [ $SSH2_IP ] ; then
SSH_FLAG=1
fi
if [ $SSH_FLAG -eq 1 ] ; then
CONN=ssh
elif [ -z $SESS_SRC ] ; then
CONN=lcl
elif [ $SESS_SRC = "(:0.0)" -o $SESS_SRC = "" ] ; then
CONN=lcl
else
CONN=tel
fi
# Okay...Now who we be?
if [ `/usr/bin/whoami` = "root" ] ; then
USR=priv
else
USR=nopriv
fi
#Set some prompts...
if [ $CONN = lcl -a $USR = nopriv ] ; then
PS1="[\u@\h \w]\\$ "
elif [ $CONN = lcl -a $USR = priv ] ; then
PS1="\[\033[01;31m\][\w]\\$\[\033[00m\] "
elif [ $CONN = tel -a $USR = nopriv ] ; then
PS1="\[\033[01;34m\][\u@\h \w]\\$\[\033[00m\] "
elif [ $CONN = tel -a $USR = priv ] ; then
PS1="\[\033[01;30m\][\u@\h \w]\\$\[\033[00m\] "
elif [ $CONN = ssh -a $USR = nopriv ] ; then
PS1="\[\033[01;30m\][\u@\h \w]\\$\[\033[00m\] "
elif [ $CONN = ssh -a $USR = priv ] ; then
PS1="\[\033[01;35m\][\u@\h \w]\\$\[\033[00m\] "
else
PS1="[\u@\h \w]\\$ "
fi
|
PS: This code is not mine!
PS2: First post! |
|
Back to top |
|
|
GenKiller n00b
Joined: 04 Mar 2003 Posts: 66 Location: United States of America
|
Posted: Tue Aug 05, 2003 6:40 pm Post subject: Re: How to prevent forgeting you're SSH'ed |
|
|
cleber wrote: | I have a similar problem, so I got this .bashrc that helps me out.
Place this code inside your ~/.bashrc in every machine you have a login.
It changes $PS1if I'm on SSH (or telner, etc).
PS: This code is not mine!
PS2: First post! |
Great first post cleber! All I modified was the colors, and took out the first two if statements under the "setting terms" section, so that Gentoo's default's still appear.
Welcome to the Forums _________________ http://www.digital-drip.com |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
|
Back to top |
|
|
|