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?
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>
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
The variables that will give you the information that you want, if they are present, are
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).