LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How do I add myself as a sudo user on a server (from the client)? (https://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-add-myself-as-a-sudo-user-on-a-server-from-the-client-4175436752/)

kp18 11-12-2012 06:46 AM

How do I add myself as a sudo user on a server (from the client)?
 
Hi all,

I will start off saying that I am a newbie to linux and not familiar with it. Here is my problem:
From my linux client, I connect to a server(via ssh) which boots with an image stored in the client.I needed to add myself as the sudo user in the server(in order to run certain commands which otherwise I don't have permission to). I modified the sudoers file of the server(which is at the client and will be copied to the server when booting) using the command:
sudo visudo

When I reboot, I can now see my username in the sudoers file in the server.But it still does not allow me to use the sudo command. What am I doing wrong?

I also tried a few other things by looking up the internet, but it will get very confusing if I list them all here, but nothing worked!

dragonix 11-12-2012 06:50 AM

When you log on to a server, you can always try to use following command to get all the priviliges

Code:

sudo su -

kp18 11-12-2012 06:53 AM

Thank you for the quick reply.
But the sudo command does not work on the server.

dragonix 11-12-2012 07:13 AM

What do you get when you use this command?

kp18 11-12-2012 07:17 AM

I get the following error:
-bash: sudo:command not found

dragonix 11-12-2012 07:44 AM

yeah oke, makes sense ;)

Try to install it with this:
Code:

# apt-get install sudo
Or, if that didn't worked
Code:

# yum install sudo
Got it from this link
Go through it and let us know if you get stuck.

cascade9 11-12-2012 07:52 AM

dragonix- I dont think that making semi-random suggestions is a good idea.

kp18- what distro and version are you using? I'd bet that you are using a distro that doesnt use sudo by default. Why are you trying to use sudo?

dragonix 11-12-2012 08:10 AM

Quote:

Originally Posted by cascade9 (Post 4827563)
dragonix- I dont think that making semi-random suggestions is a good idea.

kp18- what distro and version are you using? I'd bet that you are using a distro that doesnt use sudo by default. Why are you trying to use sudo?

I'm just giving him a link that might be helpful..

kp18 11-12-2012 09:52 AM

Thanks for the replies.

@dragonix: I have already tried those commands.Thank you.

@cascade9:

The output of 'uname -a' is:
Linux client 3.2.0-32-generic-pae #51-Ubuntu SMP Wed Sep 26 21:54:23 UTC 2012 i686 i686 i386 GNU/Linux

The 'date' on the server is not updated. The server does not permit me to update using the normal '#date' command. Hence the need for sudo.

cascade9 11-12-2012 01:32 PM

If its ubuntu, its got to be using sudo...Ubuntu is the only distro I know of that disables the root account and enables sudo out of the box (apart from other ubuntu based distros).

If you dont have sudo permissions, you probbly need to contact whoever runs it to get them.

kp18 11-12-2012 02:29 PM

Thank you cascade9. I will look into it.

I also looked into the possibility of running the 'date' command from the root, by using 'su' command to go to root. But when it asked for password and I gave mine, it said 'authentication failure'. I edited the /etc/shadow file of the server (that I can edit and view from the client)for the 'root' not to have any password.But even this did not work. Considering the fact that I also don't have sudo permissions, is there a way to overcome this hurdle of getting to the root using 'su'?

TobiSGD 11-12-2012 03:16 PM

Sorry, but all this doesn't make any sense. In post #1 you state that you changed something in the sudoers file using the command
Code:

sudo visudo
In post #3 you state that the sudo command is not working, giving you a command not found error. Only one of that statements can be true.
In post #11 you state that you have edited the shadow file, but since you don't have root permissions on that system you shouldn't be able to edit anything in /etc (especially files like sudoers), unless someone has seriously borked the permissions on the server system.

So, please show us the permissions of the files in /etc, you can do that with
Code:

ls -lh /etc
and show us the line you added to the sudoers file. Did you have done this on the client or the server. It seems that here is some serious misconception in the way of successful server administration, or you have a seriously misconfigured system.

kp18 11-14-2012 05:02 AM

@TobiSGD:Thank you for the reply.

All the files that I edited (sudoers, shadow) are on a directory in the client.The server copies these files from the client into its '/etc' directory every time it reboots(like I have mentioned in the original post). In fact when I login into the server, I can view these changes that I made. The problem was once I am in the server it did not allow me to change the 'date' because I dont have the sudo rights, and logging in as root using 'su' also did not work as it was not accepting my password(or the password I mentioned in the /etc/shadow file). I am sorry if all this sounds very confusing,because it is:).. I dont know how I can explain it better.

All said and done, now the problem is actually solved, but only through a workaround! The root password was not working when I logged into the server with my user name and then gave the command 'su'. However the same password worked when I directly login to the server using:
'ssh <server.ip.address> -l root'

So I was able to login as root user on server and set the date with the above command. But I still can't figure out why this worked and the other method did not.


All times are GMT -5. The time now is 10:38 PM.