How can i getback access to the root?

Posted February 19, 2015 4.5k views

I added a user and gave all the privileges to user by following a digital oceans tutorial. But i want to access the rails folder which has been created in the root directory. How can i get the access of root again?

  • Have you tried logging in as root?

  • Yes , it not allowing me to login to the root from my mac terminal. but i can login to root from console access in digital ocean. But I want to login to root via mac terminal.

  • Hey! Could you provide a bit more information? What was the tutorial that you followed? It sounds like you disabled root from being able to log in via SSH? Did you add PermitRootLogin no to the file /etc/ssh/sshd_config ? If so, you can just change that back to yes and restart ssh.

  • Yes, I changed PermitRootLogin to no. And yes, I tried to change it back to yes but then reload ssh shows this msg-
    reload: Rejected send message, 1 matched rules; type=“methodcall”, sender=“:1.133” (uid=1001 pid=4882 comm=“reload ssh ”) interface=“com.ubuntu.Upstart06.Instance” member=“Reload” error name=“(unset)” requestedreply=“0” destination=“com.ubuntu.Upstart” (uid=0 pid=1 comm=“/sbin/init ”)
    As u said after saving it to yes i tried restart ssh aslo, its showing the same msg-
    restart: Rejected send message, 1 matched rules; type=“method
    call”, sender=“:1.134” (uid=1001 pid=4883 comm=“restart ssh ”) interface=“com.ubuntu.Upstart06.Job” member=“Restart” error name=“(unset)” requestedreply=“0” destination=“com.ubuntu.Upstart” (uid=0 pid=1 comm=“/sbin/init ”)

  • @anishajayan It looks like you are trying to restart it as the non-root user. In that case, you’ll need to use sudo:

    sudo service ssh restart
  • Show 2 more comments

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

This question was answered by @anishajayan:

I removed AllowUsers line from sshd_config file and now I can access the root again.

View the original comment

Please how did you do it, could you provide the command step by step? I think when i was copying the public key to the new user it didn’t work, i didn’t see any message saying it was copied successful, now i set “PermitRootLogin to no” to root and tried to see the public key in the new user, it says there is nothing in that file, so i guess the copy wasn’t successful, so now i don’t know what to do, desperate here.