3

Please can anyone help - when launching Putty from a desktop machine is it possible to pass the value of the IP address of the Windows machine to the server session?

4
  • 1
    Well, do you want the IP that the windows machine thinks it is, or the IP that the server thinks the windows machine is? These may be different because of NAT.
    – Aaron
    Dec 2, 2011 at 22:24
  • Ideally I want the IP that the windows machine thinks it is because I'd like to use in conjuction with DISPLAY=10.X.X.X:0.0 export DISPLAY
    – naffcat
    Dec 2, 2011 at 22:32
  • superuser.com/questions/119792/…
    – Zoredache
    Dec 2, 2011 at 23:38
  • Many thanks - the way I'm using a Xwindows is a bit unusal - basically I launch Exceed - the do the above command with the IP. Can you tell me where this $SSH_CLIENT variable comes from - it's there on my initial login, is it being set in profile anywhere? I ask as when I sudo to another account it's gone ... is there a way to keep it?
    – naffcat
    Dec 3, 2011 at 11:13

3 Answers 3

5

If you are trying to figure out the information of the SSH client from the server after the client is connected, then look at the SSH_CLIENT variable that is probably set.

echo $SSH_CLIENT
192.168.32.26 62221 22
2
  • That works! Thankyou! - However I now realise I need to carry this into another sudo - is that possible?
    – naffcat
    Dec 2, 2011 at 23:01
  • 1
    Uhm, sure, something like this maybe? sudo bash -c "export MYTEST=${SSH_CLIENT%% *}; export" Do see the link I posted, if you are just looking for normal SSH X11 forwarding though.
    – Zoredache
    Dec 2, 2011 at 23:56
1

ideally I want the IP that the windows machine thinks it is because I'd like to use in conjuction with DISPLAY=10.X.X.X:0.0 export DISPLAY

Can't you just tick Enable X11 Forwarding on Connection->SSH->X11 ?

2
  • Thanks, that created a file .Xauthority file in my home folder but I'm not sure what I can do with it?
    – naffcat
    Dec 2, 2011 at 22:58
  • Presumably you have an Xserver running on your windows system so at a shell prompt run an X11 program ? e.g. firefox &
    – user9517
    Dec 2, 2011 at 23:02
0

Yes. You can do things like:

putty -telnet 10.1.2.3
putty -ssh 10.2.3.4
putty -serial com4

Here are the various cli arguments you can pass to the executable:

http://the.earth.li/~sgtatham/putty/0.53/htmldoc/Chapter3.html#3.7

2
  • This doesn't answer the question. The arguments you posted are simply to connect to the server at the given IP address; the OP's question is to determine the client's IP address from the shell and apply the address to an environment variable.
    – Jonathan J
    Dec 3, 2011 at 5:03
  • Yeah, sorry -- completely misunderstood the question. Zoredache has the actual answer. =)
    – Cypher
    Dec 5, 2011 at 20:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .