Skip to content

adding a new user to 0xdata machines

Kevin Normoyle edited this page Aug 19, 2014 · 25 revisions

There may be better way to handle this, but this is what I currently do.

Need to do on all machines (I use clusterssh to do this. Currently I use /home/kevin/clo to get all ubuntu machines. 192.168.1.150 and 192.168.1.151 are old centos machines. So I'm not creating new users there. I think use of them is deprecated. Means we don't have to worry about doing centos stuff and ubuntu stuff together in a tabbed ssh.

clusterssh -o "-X" -l root 192.168.1.161 192.168.1.162 192.168.1.163 192.168.1.164 192.168.1.171 192.168.1.172 192.168.1.173 192.168.1.174 192.168.1.175 192.168.1.176 192.168.1.177 192.168.1.178 192.168.1.179 192.168.1.180

Mapr requires username to have the same uid and gid on all systems, if you dispatch h2o on mapr.

I handle this manually right now. Went through a step of fixing old random uid/gid to be in sync for users on machines, so hopefully we don't let things get out of sync again (since any files created need to be adjusted if uid/gid changes)

On every machine there is some stuff I used to interrogate

cd /root/check_uid
./gather_gid1.sh
./gather_uid1.sh

If you grep the resulting files, groupreport.txt and userreport.txt, you can find the existing uids/gids in use.

I started all the new user uid/gids at 2100

The last user I added is shown below (both uid and gid should be the same)

If you grep 212 *txt, you the uids and gids on all current, and pick the next biggest incremental number in the 21xx series

To add a user (need to do this as root)

Note the group needs to be created first The list of secondary groups is what may be useful at 0xdata (we have 3 hdfs clusters with some special users and groups. Security within their hdfs filesystems is a whole 'nuther discussion!

addgroup --gid 2124 brandon
adduser --uid 2124 -gid 2125 brandon
usermod -a -G 'sudo,hduser,mapr,hdfs,mapred,0xdiag' brandon

Advanced: it's possible to reclaim old unused users, and their gid/uid by renaming the user and his home dir.

.bashrc may have been customized so should be copied from a virgin source. Check user groups and login behavior if you do this method. Get the command right otherwise user and groupname will be in an odd state and take more work to recover from http://www.ubuntututorials.com/change-username-ubuntu-12-04/

usermod -m -d /home/oldname -l newname oldname
groupmod -n newname oldname
mv /home/oldname /home/newname
chown newname:newname -R /home/newname
usermod -d /home/newname newname

or maybe it's better to remove the user then add new user with the old gid/uid i.e

userdel irene
rm -rf /home/irene
addgroup --gid 2108 radu
adduser --uid 2108 -gid 2108 radu
usermod -a -G 'sudo,hduser,mapr,hdfs,mapred,0xdiag' radu

It's good to redo this when you're done

cd /root/check_uid
./gather_gid1.sh
./gather_uid1.sh

and grep the txt files created for the old/new username/groupname, to make sure everything is as expected. And

ls /home/newname
ls /home/oldname

Look for old hidden files like

/home/newname/.bash_history 
/ome/newname/.viminfo  
/home/newname/.vimrc 

etc

Clone this wiki locally