1

If I am logged into a Solaris server from my Windows laptop via putty using ssh, how, on the server, can I determine my Windows laptop IP or hostname?

4
  • What version of Solaris is it? Do either of the who or w commands show this information? Do you have the SSH_CLIENT and/or the SSH_CONNECTION variables in your environment? (e.g. run env | fgrep SSH) - but be careful, if you have set up a VPN or traversing a router using NAT, the source IP address might not be your actual IP address. Commented Nov 21, 2015 at 3:00
  • I am using solaris 10. Commented Nov 21, 2015 at 23:21
  • Thanks Murray both SSH_CLIENT and SSH_CONNECTION variables were set and that took care of what I wanted to do. Commented Nov 23, 2015 at 8:49
  • @MurrayJensen, you should convert your comment into a proper answer... Commented Nov 24, 2015 at 16:41

2 Answers 2

2

The SSH server (your Solaris server, in this case, but it's not limited to Solaris) will usually insert a set of variables into your environment on the remote computer (prefixed with SSH_).

The variables that will give you the information that you want, if they are present, are SSH_CLIENT and/or SSH_CONNECTION (see this).

SSH_CLIENT shows the address of the client system, the outgoing port number on the client system and the incoming port on the server. SSH_CONNECTION shows the address of the client, the outgoing port on the client, the address of the server and the incoming port on the server.

The examples given are:

SSH_CLIENT='192.168.223.17 36673 22' SSH_CONNECTION='192.168.223.17 36673 192.168.223.229 22' 

You can list all the ssh environment variables by running the command env | grep '^SSH_'.

However, be aware that if you have set up a VPN or are traversing a router using NAT, the source IP address might not be your actual local IP address (e.g. in the case of NAT, it will be the address of your router).

2

who am i will show you who are you, and from where you are connected

root@solaris10$ who am i root pts/4 Oct 18 18:13 (192.168.1.4) root@solaris10$ 

It could be you will be unable to get your Windows Terminal address, here 192.168.1.4 belongs to a firewall but can be a gateway also.

In some cases, depending of your network configuration, your IP can be found on the Solaris server. If you have your IP addess you can sniff the activity by using:

snoop -r -d <device> <your_IP> 

The result will be something like this:

root@solaris10 # snoop -r -d ce0 10.24.4.87 Using device ce0 (promiscuous mode) 10.24.4.87 -> 10.24.0.25 TCP D=22 S=54233 Syn Seq=3843238285 Len=0 Win=8192 Options=<mss 1380,nop,wscale 8,nop,nop,sackOK> 10.24.4.87 -> 10.24.0.25 TCP D=22 S=54233 Syn Seq=3843238285 Len=0 Win=8192 Options=<mss 1380,nop,wscale 8,nop,nop,sackOK> 10.24.4.87 -> 10.24.0.25 TCP D=22 S=54233 Syn Seq=3843238285 Len=0 Win=8192 Options=<mss 1380,nop,nop,sackOK> 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.