sshdynamic-ip

How to check if username is valid on a ssh server


How can I check if a username exists at a ssh server address using command line tools? For example, I would love to type,

isvaliduser [username] [ssh_server]
result: True

where isvaliduser is some magical function that tests whether a user with name username exists at ssh_server. But is this feasible?

My specific application: The remote server I need to access has a dynamic IP (I can't use a Dynamic DNS service). I can come up with a list of server addresses that contains my target address, but I need a way to figure out which one is mine. I thought one way of doing this would be to test if any of the addresses have the user myusername. But if you have another suggestion for solving my particular problem, I would be happy to hear it.


Solution

  • You have to connect to that server and check if the user is in the passwd for example:

    ssh your_account_at_serve@[ssh_server] grep [username] /etc/passwd
    

    If you would be able to enumerate users without authentication, it is considered as a information disclosure and security threat.