I have a not so unix question for you guys(or maybe it is). I use PUTTY to login to serverA (my putty title shows as serverA.domainname.com)
Now from ServerA i do ssh user@ServerB (i have ssh public private key setup)...
now my question is when i do ssh and logon to serverB...my putty title still shows as serverA.domainname.com....is there anyway to "AUTOMATICALLY" change that to ServerB.domainname.com without going into putty menu and stuff ???
---------- Post updated at 12:15 PM ---------- Previous update was at 12:11 PM ----------
i know i can use something like below to change the title..but how can it be down automatically ?? without change profile and stuff on each server i do ssh to
Thanks for the info...but i do not want to put in this all the server, we have well over 600+ servers...it would be painfull to do that....anyway to do this inside ServerA and when i ssh to serverB or serverC....it chanages automatically ?
$ ssh oracle@serverB export PS1="whatever" exec /bin/sh
ksh: /bin/sh: is not an identifier
$
$
$ which sh
/usr/bin/sh
$
$
$ ssh oracle@serverB export PS1="whatever" exec /usr/bin/sh
ksh: /usr/bin/sh: is not an identifier
$
You can replace ssh with your own function. So when you type ssh, you set title, execute real ssh, then set the title back. Try this in profile on ServerA:
ssh() {
local args=( "$@" )
#try find out destination
while [[ $1 = -* ]]; do shift; done
printf '\033]0;%s\007' "$1"
command ssh "${args[@]}"
printf '\033]0;%s\007' "$USER@$HOSTNAME"
}
Sorry I just now saw you use ksh. I have mksh and it allows local but you must split that to two lines. I am not well read on ksh.
local args
args=( "$@" )
edit: that function is by no means a complete wrapper. many ssh options take arguments (i.e. ssh -p 123 user@host ). if you never use options, the function can be made a lot simpler (always use $1 as title), otherwise it can be made a lot lengthier to shift through them.
I know this is an old post, but wanted to bring it up. This works perfectly fine for putty....i have something like below that change my putty title when i do
ssh username@server name....
# SSH Wrapper
ssh()
{
set -A args "$@"
#try find out destination
while [[ $1 = -* ]]; do shift; done
printf '\033]0;%s\007' "$1"
command ssh "${args[@]}"
printf '\033]0;%s\007' "`whoami`@`hostname`"
}
But now i have a question with regards to another tool...Putty connection manager or any other Tabbed style putty tool...the title dose not seems to change...is there anything special i need to do to get that changed for putty connection manager??