Click to See Complete Forum and Search --> : Finding my Ip


PlanetBOB
05-06-2002, 06:27 PM
I use ssh on my Win2k box to connect to my Mandrake linux box, and want to build a script that shows what ip i logged in from.

win2k box <-- ssh --> Mandrake linux Box
You logged in from ip:
???.???.???.???

also can i set it as an eviroment variable?

I have done a bit of searching, but not entirely sure what it is i am looking for.

so any help or links you might be able to provide, would be greatly appreciated.

Lorithar
05-06-2002, 07:39 PM
Umm ..
my system logs ssh logins in /var/log/info
Your userid is automagically included in your env at login.

soooo

LOGIN_FROM_IP=`tail -100 /var/log/info |grep sshd |grep $LOGNAME |awk '{ print $11 }' `
(in my case the ip address is the 11th "word" in the line considering spaces as the separators...

-- may I ask WHY you wish to do this?

PlanetBOB
05-06-2002, 08:18 PM
/usr/X11R6/bin/xauth: (stdin):1: bad display name "PlanetBOB:10.0" in "add" command


I get this error message on login... not sure what i did to set it this way, so i have to manually set DISPLAY everytime i want to use xterm, so i figured making a small script, like:

export DISPLAY=IpLoggedInFrom
xterm

would kinda be easier than trying to figure out how to fix the error message, for now atleasts, since i am total newbie to linux, but i do know how to make small bash scripts.