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?

naffcat
  • 31
  • 1
  • 1
  • 2
  • 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 02 '11 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 02 '11 at 22:32
  • http://superuser.com/questions/119792/how-to-use-x11-forwarding-with-putty/119908#119908 – Zoredache Dec 02 '11 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 03 '11 at 11:13

3 Answers3

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
Zoredache
  • 130,897
  • 41
  • 276
  • 420
  • That works! Thankyou! - However I now realise I need to carry this into another sudo - is that possible? – naffcat Dec 02 '11 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 02 '11 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 ?

user9517
  • 115,471
  • 20
  • 215
  • 297
  • Thanks, that created a file .Xauthority file in my home folder but I'm not sure what I can do with it? – naffcat Dec 02 '11 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 02 '11 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

Cypher
  • 1,077
  • 2
  • 17
  • 24
  • 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 03 '11 at 05:03
  • Yeah, sorry -- completely misunderstood the question. Zoredache has the actual answer. =) – Cypher Dec 05 '11 at 20:17