1

I'm having trouble finding the solution to my problem, which I believe is just a noob thing. I've just set up my first VPS using WHM and CPanel. I'm using Putty for SSH access.

I can login to SSH with my CPanel account (not root account). I need to configure some files that I believe are only accessible as the root/sudo user, such as: /etc/ssh/sshd_config among others. From WHM under SSH Password Authorization Tweak, it says that Password Authentication is enabled, but I cannot login as root via SSH. I get access denied. I also cannot sudo su my regular acct because it says the user is not in the sudoers file. I can't add them to the file because I don't have access to it without logging in as the root user.

Finally, I have tried using SSH keys set up via WHM, but the server refuses the signature despite accepting accepting the key and then asks me for root password, where I once again get Access Denied.

How am I supposed to change files that only the root/sudo user have access to but I cannot SSH as root or sudo user without initial root access?? This is nuts. I really think I'm missing something obvious here, but I just don't know what. Thanks so much for your help.

  • 1
    You can't, since it is an unprivileged account with no access to sudo. That is basically the whole point of separating admins and non-admins. – mikewhatever Apr 29 '17 at 0:50
  • I should be more clear, I am the only person with access to my VPS. I have the root w/ password, but cannot login via SSH to access the files I need to configure my server to serve my website. Apparently, to enable my access, I need to edit a file that only the root user has access to via SSH. – ionalchemist Apr 29 '17 at 1:09
0

As "mikewhatever" said, it's because of permissions or, if you prefer, groups. Meaning that:

To solve your problem you'll need to add the username used for SSH to this command: sudo usermod -a -G sudo username. Then just change the "username" to the actual username and input root password when asked for it (root password, or rather just the password for your account that already has permissions to execute sudo).

  • Unfortunately every sudo command I issue in SSH comes back and says my username is not in the sudoers file. This incident will be reported. And wouldn't you know, a few seconds later, I get an email reporting it....ha – ionalchemist Apr 29 '17 at 1:13
  • Do you have an account where you CAN do things like sudo -s? If so, open a terminal in that account and issue the command there. And I repeat: out of SSH, in terminal from your user with sudo privileges. – ulovah Apr 29 '17 at 1:15
  • I don't I'm afraid. My server is set up through GoDaddy. I've heard that that may not be the best and perhaps that's where my problem lies. As of now, I have no root access to my system (except via WHM). – ionalchemist Apr 29 '17 at 1:19
  • I thought you said you had "root /w password"...? If you have that, you should be able to do su, right? – ulovah Apr 29 '17 at 1:22
  • It won't allow me to do it. I get Access Denied. But I can login to WHM with the same credentials as root user. – ionalchemist Apr 29 '17 at 1:23
0

This is kind of lame in my opinion to be an actual solution to the problem, but I did finally figure out how to login to my account with root access. I am hosting with GoDaddy and when you set up your virtual private server with them, you are asked to create a user for your server, which I did. What I did not realize when performing this step is that the username I selected would also be the username I needed to use in ssh for root access. I was trying to log in with root as the username and failing. When I finally tried logging in with the username that GoDaddy asked me for when creating my VPS, I was able to login with root access. I decided to post my answer in case anyone else runs into this very issue. I also added "GoDaddy" to my question realizing that this issue could be isolated to the way they set you up with a VPS (and don't support btw).

Many thanks to @ulovah for all your help. You helped me rule out many possibilities.

0

login as normal user and then enter sudo su - for Managed & Fully Managed Linux Servers and su - for all other linux servers.

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.