After connecting to ssh, through which command can I find the ip address from which the current connection is established? Those. I need to find out if I connected to ssh via VPN and hid my real ip or traffic goes directly.
1 answer
According to man ssh there is such an environment variable:
SSH_CONNECTION Identifies the client and server ends of the connection. The variable contains four space-separated values: the client IP address, the server port number, the server IP address, and the server port number.
$ echo $SSH_CONNECTION 192.168.0.123 41412 192.168.0.1 22 The first ip is the client's address (from the point of view of the sshd daemon, which adds this variable to the environment of the program launched as a result of the connection, usually the shell).
With a simple operation, this address can be separated from the rest of the variable. eg:
$ echo $SSH_CONNECTION | cut -d ' ' -f 1 192.168.0.123 |