After connecting to ssh, through which command can you find out the ip address from which the current connection is established? Those. I need to find out if I have connected to ssh via VPN and have hidden my real ip or if the traffic is going directly.
man ssh there is an environment variable like this:
SSH_CONNECTION Identifies the client and server ends of the connection. The variable contains four space-separated values: client IP address, client port number, server IP address, and server port number.
$ echo $SSH_CONNECTION 192.168.0.123 41412 192.168.0.1 22
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 a shell).
With a simple operation, this address can be separated from the rest of the contents of the variable. For example:
$ echo $SSH_CONNECTION | cut -d ' ' -f 1 192.168.0.123