After password-less ssh-login, is there any way in Linux to retrieve the identity of the remote-user that logged in?
I would like to take some different actions in the login-scripts,
depending on from which remote host/userid I do ssh-login.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The originating system’s username is not recorded unless you use something like this answer – i.e. push the username as part of the connection. The remote host is encoded in the
SSH_CLIENTenvironment variable, so that can be determined.You could try to
fingerthe remote system, but that requiresfingerdto be running, which is not a common service these days.You’ll have better luck using specific keys for users, which can have options set at the start of the key such as
environment="NAME=value"in theauthorized_keysfile to kind-of determine the remote user that connected. e.g.The use of the
environmentoption in the key will only work if you’ve gotPermitUserEnvironmentset in the sshd config, otherwise the line in theauthorized_keysgets ignored and you’ll be prompted for a password.