From Mageia wiki
Jump to: navigation, search

Rename user

From time to time it is necessary to rename a user. This may be for cosmetic reasons or it could related to issues with the username such as it containing characters that cause problems with various bits of the infrastructure.


The actual user rename

As users are stored in LDAP, this requires interaction with the primary LDAP server.

Let's say that olduser is the username that we wish to change.


 [root@valstar ~]# ldapmodify -H ldaps://ldap.mageia.org -D uid=yourusername,ou=People,dc=mageia,dc=org -W

Note the use of yourusername above in the bind DN. This is, as the text suggests *your* username.

It will prompt you to enter a password. After entering the password correctly you'll just be given a blank line. Continue and type:

 dn: uid=olduser,ou=People,dc=mageia,dc=org
 changetype: modrdn
 newrdn: uid=newuser
 deleteoldrdn: 1


Press return on a blank line at the end and you should get:

 modifying rdn of entry "uid=olduser,ou=People,dc=mageia,dc=org"


That's it! You can just ctrl-d out of the ldapmodify shell after that. You can also write these commands to an LDIF file if you prefer.


You can then use the http://identity.mageia.org website to correct the home directory or fight some more with ldapmodify to change this if you're a masochist.

You should then renmae the actual homedir on valstar:

 [root@valstar ~]# mv /home/olduser /home/newuser


And confirm this change worked:

 [root@valstar ~]# getent passwd newuser
 newuser:*:5123:5000:Joe User:/home/olduser:/usr/local/bin/sv_membersh.pl

Hmm, it didn't work??? But perhaps it's a caching issue:

 [root@valstar ~]# nscd -i passwd
 [root@valstar ~]# getent passwd newuser
 newuser:*:5123:5000:Joe User:/home/newuser:/usr/local/bin/sv_membersh.pl

That's better!

Other updates/propigating the change

Although it's run by cron, and the home directory is manually renamed, it is probably wise to run:

 [root@valstar ~]# /usr/local/bin/ldap-sshkey2file.py

to generate ssh key files (i.e. the authorized_keys).

If the old user maintains any packages, it is easiest to bulk change any maintainer db files with references to the old user:

 [root@valstar ~]# sed -i 's/^olduser$/newuser/' /var/lib/maintdb/db/*

And to keep the generated people pages up-to-date, it's nice to run:

 [root@alamut ~]# mkpeople
 [root@alamut ~]# rm -f /var/www/vhosts/people.mageia.org/u/olduser.html