Score:0

How to find the username who performed SSH?

bl flag

When one does ssh oracle@hostB on a local host say A, will the hostB know the user who performed SSH on host A? Is there a way to find out the username who performed SSH?

in flag
Can I clarify the question? You have multiple people SSHing into a machine using `oracle@hostname`, and you want to know *which* person signed in as `oracle` at that time?
damn harshitha avatar
bl flag
@matigo yes, you're right
pLumo avatar
in flag
No, there is no way.
Score:2
cn flag

When using ssh, you log in to the remote computer hostname as one of the users know to that remote computer. Thus, anyone logging in on as user oracle will be known as that single user on the remote computer.

If you want to differentiate who logs in on the remote computer, then give each user his own account. Administer your system, i.e., set umasks, ownerships and permissions or use ACL extended permissions, to make sure any user can do what that user is expected to do.

Score:0
cn flag

If it helps:

If you set the server up so that people use public and private keys to log in (and deny passwords), the key used to log into the server is recorded in the system log files by the ssh daemon.

You can find out the matching key by running the following command on all the public keys until you find a match

ssh-keygen -lf ~/.ssh/xxxx.pub

where xxx is the name of a public key, when the output matches the log file entry you have the identity of the user connecting to the server.

Score:0
cn flag
raj

By "host A", do you mean the host on which the command ssh oracle@hostname is performed, or the remote host hostname?

In the first case, obviously the name of the local user who performs the command is known to the local host. It is stored for example in environment variables LOGNAME or USERNAME, or may be obtained using the command id -un.

If you want to eg. record that name, you can replace the ssh binary with a wrapper script, that gets the local user name using any of the above methods, writes it to some logfile together with a timestamp, and then calls the "real" ssh binary with the original arguments provided to the script.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.