Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
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 '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 2 '11 at 22:32
    
    
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 '11 at 11:13

3 Answers 3

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 ?

share|improve this answer
    
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 '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 & –  Iain Dec 2 '11 at 23:02

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
share|improve this answer
    
That works! Thankyou! - However I now realise I need to carry this into another sudo - is that possible? –  naffcat Dec 2 '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 2 '11 at 23:56

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

share|improve this answer
    
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 '11 at 5:03
    
Yeah, sorry -- completely misunderstood the question. Zoredache has the actual answer. =) –  Cypher Dec 5 '11 at 20:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.