LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-12-2019, 11:53 PM   #1
upnort
Member
 
Registered: Oct 2014
Distribution: Slackware, Proxmox, Debian, CentOS, Ubuntu MATE
Posts: 804

Rep: Reputation: Disabled
Validating ownership against /etc/passwd and /etc/group


Looking for ideas for how to validate ownerships against /etc/passwd and /etc/group.

I had to rebuild a server and then restore selected files from backups. All went well.

Except I noticed the /etc/passwd and /etc/group files no longer match the other similar servers or the same files from backups. Makes some sense because the rebuild was performed with a more recent ISO of the system.

For example:

Old /etc/passwd:
sshd:x:105:65534::/var/run/sshd:/usr/sbin/nologin

New /etc/passwd:
sshd:x:106:65534::/run/sshd:/usr/sbin/nologin

Because of the selective backups, I want to validate that the ownerships of all restored files match the newer /etc/passwd|group files. I could restore those same files from backups, but I don't know what will break.

I am not noticing anything in the logs, but I would be more comfortable with some kind of validation.

Thanks again.
 
Old 01-13-2019, 01:33 AM   #2
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 2,314

Rep: Reputation: 756Reputation: 756Reputation: 756Reputation: 756Reputation: 756Reputation: 756Reputation: 756
Selectively update the contents of /etc/passwd, /etc/shadow and /etc/group from the backups to the new server.

That is, make the passwd, shadow and group files match...don't try to tweak the files themselves.

I typically do that as early in the build as possible.

Last edited by scasey; 01-13-2019 at 01:35 AM.
 
Old 01-13-2019, 06:36 PM   #3
upnort
Member
 
Registered: Oct 2014
Distribution: Slackware, Proxmox, Debian, CentOS, Ubuntu MATE
Posts: 804

Original Poster
Rep: Reputation: Disabled
Quote:
That is, make the passwd, shadow and group files match...don't try to tweak the files themselves.
Hmm. I'm feeling a bit dense and am not followwing you.
 
Old 01-13-2019, 06:57 PM   #4
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.5
Posts: 2,314

Rep: Reputation: 756Reputation: 756Reputation: 756Reputation: 756Reputation: 756Reputation: 756Reputation: 756
Quote:
Originally Posted by upnort View Post
Hmm. I'm feeling a bit dense and am not followwing you.
You set up new server, user sshd is UID 106, was UID 105 in backup data.
Change UID to 105 in /etc/passwd on the new server to match the backup data.
Repeat for all non-matching UIDs on new server.
 
Old 01-13-2019, 10:22 PM   #5
upnort
Member
 
Registered: Oct 2014
Distribution: Slackware, Proxmox, Debian, CentOS, Ubuntu MATE
Posts: 804

Original Poster
Rep: Reputation: Disabled
OK.

My focus though is discovering whether there are any files/directories created from within the new install that are using the new UIDs/GIDs. I suppose I could run 'find / -user $NewUID', 'find / -group $NewGID', etc. That way I would know what files/directories are affected before restoring the old UIDs/GIDs.

Perhaps also the reverse -- using the old UIDs/GIDs. Then there is discovering any files/directories that are not using the installed or backed up UIDs/GIDs. I was hoping for some kind of automated method, but I can manually run one command at a time. Time consuming but doable.
 
Old 01-14-2019, 12:04 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,589

Rep: Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433Reputation: 2433
If this is an rpm based system, see https://linux.die.net/man/8/rpm (rpm -V) & https://www.cyberciti.biz/tips/reset...ermission.html
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Legacy Account in /etc/passwd, /etc/shadow and/or /etc/group lalit singhania Linux - Newbie 4 06-07-2012 07:33 AM
Problem with /etc/passwd and /etc/passwd- files linuxravindra414 Linux - Newbie 2 01-15-2011 06:17 AM
[SOLVED] /etc/passwd- & /etc/shadow- & /etc/group- Mr. Alex Linux - Newbie 1 12-31-2010 06:19 AM
Doubt when creating a user and checking /etc/group and /etc/passwd rosepower Slackware 9 04-18-2007 06:56 PM
/etc/passwd, /etc/shadow, /etc/group? Educate me :)! nutnut Linux - General 4 06-11-2005 08:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration