Thursday, June 15, 2017

Migrating user accounts from older Linux to RHEL7 / CentOS7

Another pointless change just to break backwards compatibility - RHEL7 and CentOS7 prevent users with uid lower than 1000 from logging in. This is bad when you're migrating accounts from existing Linux server where uids start at 500.

Number of configuration files under /etc/pam.d enforce this limit. Editing them by hand works until next time authconfig is executed and then default setting is back.

Fix this by editing /etc/login.defs and change UID_MIN and GID_MIN from default 1000 to 500.
Then run "authconfig --update"

/etc/pam.d/password-auth:auth        requisite uid >= 1000 quiet_success
/etc/pam.d/password-auth:account     sufficient uid < 1000 quiet

/etc/pam.d/password-auth:auth        requisite uid >= 500 quiet_success
/etc/pam.d/password-auth:account     sufficient uid < 500 quiet

I used following commands to migrate user logins with passwords. Rest is easy - just rsync home directories across the network or do NFS mount.

awk -F: '{if ($3 >= 500 && $3 < 1000) { print } }' passwd.gramps >>/etc/passwd
awk -F: '{if ($3 >= 500 && $3 < 1000) { print } }' group.gramps >>/etc/group
awk -F: '{if ($3 >= 500 && $3 < 1000) { print $1 } }' passwd.gramps | egrep -f - shadow.gramps >>/etc/shadow

And grant sudo access by adding to my login to wheel group.

usermod -aG wheel asiantuntijakaveri


  1. I have been exploring for a little for any high-quality articles or
    blog posts in this kind of house . Exploring in Yahoo I at last stumbled upon this site.
    Reading this information So i am glad to show that
    I have an incredibly good uncanny feeling I discovered exactly what I needed.
    I most for sure will make sure to do not forget this website and
    provides it a glance on a constant basis.


  2. whoah this blog is fantastic i love reading your posts. Keep up the great work! You know, lots of people are looking around for this information, you could aid them greatly.


  3. I believe this is among the so much significant information for me.
    And i'm happy reading your article. 스포츠토토

  4. Greetings! Your blog is very interesting! Please check my website I have a recommendation for you 토토


Got something to say?!