On a unix server, I need always do sudo su - superusername Due to this no two or more people can work simultaneously on a process. I need to remove this overhead by removing the sudo step. Every user will have its own profile and they will no more share the same environment by doing sudo. Kindly help how can I create a user with same privileges as of superusername.
You can use these command to do that but it is not a good idea to give root priveledge to normal user
$ sudo useradd -ou 0 -g 0 username
Little Extra : This to set password to the new user you have created
$ sudo passwd username
Related
I managed to follow all the steps to create EC2 instance and install R Server on it.
When I go to RStudio Server page to connect (which looks something like "ec2-[Public IP]-.eu-west-3.compute.amazonaws.com:8787"), I am asked a username and a password.
I figured out to set a username ("user1") this way:
$ sudo useradd user1
But then when I try this command to write the password:
echo user1:password | chpasswd
I receive this message:
chpasswd: cannot lock /etc/passwd; try again later.
I looked at different solutions suggested here:
https://superuser.com/questions/296373/cannot-lock-etc-passwd-try-again-later
but I do not see a resolution to my problem.
I did not find either any passwd.lock, shadow.lock, group.lock, gshadow.lock files to remove.
type in 'sudo passwd your_username' and you will be prompted to enter a new password
This question already has answers here:
Linux: 'Username' is not in the sudoers file. This incident will be reported [closed]
(11 answers)
Closed 2 years ago.
I am trying to add a particular user in the group using command: sudo usermod -a -G groupname username.
but getting error as "Username is not in the sudoers file. This incident will be reported".
I dont have any idea about sudoers file. Can anybody please help me on this.
The config file /etc/sudoers lists the users who are allowed to run which commands as which user.
On Ubuntu, this file contains a line allowing all users of the sudo group to run commands as the root user.
To check which users are in the sudo group you can type getent group sudo. You can also check the groups of your current user by typing id.
To allow another user to run sudo, you can add them to the sudo group:
sudo adduser username sudo
Or, if your current user can't run sudo, you will need to boot into "Recovery mode" from Grub (hold shift while booting, if your grub menu doesn't show up automatically), or add single to the linux ... initrd ... quiet splash line, then:
mount -o rw,remount /
adduser username sudo
Run adduser for each user you want to be able to sudo. Then exit & resume.
How do I get root access to my Google VM instance, and also how can I log into my VM Instance from my PC with a SSH client such as putty?
I would also like to add that I have tried to do sudo for things that need root access to do those things, such as yum or wget. But it does not allow me to do sudo, it asks me for the root password but I do not know how, or where I would be able to get the root password.
You can become root via sudo su. No password is required.
How do I use sudo to execute commands as root?
(splitting this off from the other answer since there are multiple questions within this post)
Once you connect to your GCE VM using PuTTY or gcloud compute instances ssh or even clicking on the "SSH" button on the Developers Console next to the instance, you should be able to use the sudo command. Note that you shouldn't be using the su command to become root, just run:
sudo [command]
and it should not prompt you for a password.
If you want to get a root shell to run several commands as root and you want to avoid prefixing all commands with sudo, run:
sudo su -
If you're still having issues, please post a new question with the exact command you're running and the output that you see.
sudo su root <enter key>
No password required :)
if you want to connect your gce (google-cloud) server with putty using root, here is the flow:
use puttygen to generate two ppk files:
for your gce-default-user
for root
do the followings on putty (replace gce-default-user with your gce username):
Putty->session->Connection->data->Auto-login username: gce-default-user
Putty->session->Connection->SSH->Auth->Private-key for authentication: gce-default-user.ppk
Then connect to server using your gce-default-user
make the following changes in sshd_config
sudo su
nano /etc/ssh/sshd_config
PermitRootLogin yes
UsePAM no
Save+exit
service sshd restart
Putty->session->Connection->data->Auto-login username: root
Putty->session->Connection->SSH->Auth->Private-key for authentication: root-gce.ppk
Now ou can login to root via putty.
If you need to use eclipse remote system and log-in as root:
Eclipse->windows->preferences->General->network Connection->SSH2->private-keys:
root-gce.ppk
Please try sudo su - on GCE.
By default on GCE, there is no password required to sudo (do as a substitute user). The - argument to su (substitute user) further simulates a full login, taking the target user (the default user for both is root) configured login shell and its profile scripts to set new environment parameters. You'll at least notice the prompt change from ending in $ to # in any case.
JUST GOT TO CLOUD SHELL BY CLICKING SSH
AND FOLLOW PASSWORD CHANGE COMMAND FOR ROOT USER USING SUDO :)
sudo passwd
and it will change the root password :)
then to becom root use command
su
type your password and become a root :)
How do I connect to my GCE instance using PuTTY?
(splitting this off from the other answer since there are multiple questions within this post)
Take a look at setting up ssh keys in the GCE documentation which shows how to do it; here's the summary but read the doc for additional notes:
Generate your keys using ssh-keygen or PuTTYgen for Windows, if you haven't already.
Copy the contents of your public key. If you just generated this key, it can probably be found in a file named id_rsa.pub.
Log in to the Developers Console.
In the navigation, Compute->Compute Engine->Metadata.
Click the SSH Keys tab.
Click the Edit button.
In the empty input box at the bottom of the list, enter the corresponding public key, in the following format:
<protocol> <public-key> username#example.com
This makes your public key automatically available to all of your instances in that project. To add multiple keys, list each key on a new line.
Click Done to save your changes.
It can take several minutes before the key is inserted into the instance. Try connecting with ssh to your instance. If it is successful, your key has been propagated to the instance.
I have to login more then 150 sever and execute some unix commands.
The problem is, if I create a script which will run from one server and ssh login to 150 server and execute cmds and exit.
How can i login with any password prompt.
due to some reason i should not use ssh-keygen public and private key method , or use of some extra tool with bash line like "expect".
is there any normal way to do login through ssh in single command consisting username/password#servername like we have option in sqlplus and ftp.
There is a utility called sshpass that allows you to specify a password in the commandline.
Under Ubuntu/Debian install by using sudo apt-get install sshpass
sshpass -p 'abcedf' ssh joe#myserver.domain.com "df > ~/test; cat ~/test; rm ~/test;"
hope this helps
You can try setting up either ~/.shosts or /etc/ssh/shosts.equiv on each of your remote hosts. See man ssh under "AUTHENTICATION" for details.
I have a wrapper script which calls two scripts aaa.sh and bbb.sh. These two scripts should be executed as different users as
sudo -H -u user1
. /user/bin/scripts/aaa.sh
sudo -H -u user1
. /user/bin/scripts/bbb.sh
but the sudo command can't be executed inside a script. Need help...
If you just want to switch users, you should use 'su' not sudo, right?
su user1 -c ./user/bin/scripts/aaa.sh
(that is unless you actually do need elevated privileges)
sudo can be used inside a script, but is the user that executes this script actually allowed to use sudo? Check your /etc/sudoers file.
sudo can be used only if the user name is mapped in /etc/sudoers file as mentioned above. But he may not have the complete priveleges as compared to su user.