How can i getback access to the root?

February 19, 2015 1.7k 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?

7 comments
  • 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
    
  • when i did sudo service ssh restart, it display- "ssh stop/waiting
    ssh start/running, process 27591" . Then i tried logging into root by - "ssh root@ip_address" ,its displaying- "Permission denied, please try again." I used the same password in digital ocean console, and it logged me in there.But in mac terminal its displaying the above msg.

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

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.

Have another answer? Share your knowledge.