Verify remote user identity after ssh-login password?

After the ssh-login password, is there a way in Linux to get the identity of the remote user who is logged in?

I would like to take several different actions in login scripts, depending on which remote host / user I am doing ssh-login from.

+4
source share
1 answer

The original system username is not written unless you use something like this answer - i.e. click the username as part of the connection. The remote host is encoded in the SSH_CLIENT environment variable, so it can be defined.

You can try the remote finger system, but that requires fingerd , which is currently not a regular service.

You will be able to use certain keys for users, which may have parameters set at the beginning of the key, such as environment="NAME=value" in the authorized_keys file, to determine how the remote user connects. eg.

 environment="REMOTEUSER=fred" ssh-rsa <blahblahkey> <comment> 

Using the environment parameter in the key will work only if you set PermitUserEnvironment to the sshd configuration, otherwise the line in authorized_keys will be ignored and you will be asked to enter the password.

+5
source

All Articles