How will you ssh into some other system's root account? Assume that you have to access to target system.

This is a question I was asked in a quiz. Apparently simply using

ssh root@192.168.xx.xx

wasn't the answer. I'd like to know the answer.

  • 1
    I am guessing the interview went poorly? This took me 15 seconds of googling to answer. As an example: askubuntu.com/questions/511833/cant-ssh-in-as-root. One very important skill in the tech industry is learning how to learn. And like every other skill, it will improve with practice. Good luck, practice hard. Mar 7 '17 at 8:13
  • Could it be the question was not "how do you ssh into the root account of some other system", but "how do you change the configuration of sshd to be able to do that"?
    – dirkt
    Mar 7 '17 at 11:53
  • I didn't know I had to change the configuration of sshd Mar 7 '17 at 11:54
  • 4
    I think "Assume you have access to the target system" at least partly allows you to assume that the any restriction on sshing directly to root had been lifted (as opposed to, say, "Assume the target system is in its default configuration").
    – TripeHound
    Mar 7 '17 at 13:01
  • 1
    Your answer is correct. Anything beyond ssh root@some-other-system can only be a guess since the question doesn't mention configuration or other details.
    – user36078
    Mar 7 '17 at 15:47

That is actually the proper way to SSH into a server (192.168.xxx.xxx), that accepts SSH connections on the default port (22). To specify the user you want to use for login, you can use:

ssh -l root 192.168.xxx.xxx


ssh root@192.168.xxx.xxx

If the SSH service is configured to allow root login, you should be able to connect without problems (PermitRootLogin yes, under sshd_config).

  • That wasn't the answer Mar 7 '17 at 8:15
  • I am assuming the point of the question is that many machines are locked down for root login.... Mar 7 '17 at 8:19
  • 20
    I have to add my opinion here, sorry. This answer and answer provided by rajeev_r_menon on interview is 100% correct. I'd say that the guy on the other side messed up. Yes, it is common in Debian OS family to disable root login via ssh, but RedHat, on the other hand, still permits it by default. I have port knocking configured, should I also mention this in my answer? If you do an interview DON'T expect that someone will guess what you meant, just add next question - "And what if you get permission denied? What can be a cause of it?"
    – Kalavan
    Mar 7 '17 at 9:24
  • 2
    Also, PermitRootLogin yes is only for the OpenSSH ssh server implementation. Also, many systems have other ways to disable root login over the network like via PAM on some GNU/Linux systems. Mar 7 '17 at 12:52
  • 2
    This is the correct answer. Disabling root login via ssh provides no security benefits assuming you're using pubkey auth, and the alternatives (su, sudo, etc.) have much worse security properties. Whoever wrote the quiz is probably cargo-culting bad ideas and wants you to show your knowledge of whatever wrong approach they think is better.... Mar 7 '17 at 16:32

Disable root login and then SSH in as yourself and use privilege escalation (sudo, su root...) when needed. You now have traceable root access as sudo etc are logged.

  • 2
    We have to login into the "root" account itself. It's not about root permission. Mar 7 '17 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.