James Harris <
james.h...@gmail.com> wrote:
> On 10/03/2021 16:15, Rich wrote:
>> Joe Beanfish <joebe...@nospam.duh> wrote:
>>> Another possibility, since you're cloning between machines anyhow,
>>> clone the password files too. Doesn't involve any extra services
>>> or failovers and may be plenty sufficient for your use case.
>
> I thought about that but wasn't sure whether passwords would be
> encrypted with the same algorithm on different machines.
Unless you are running an anchient distro (as in 1995 vintage) then no.
The encrypted data in the shadow file includes a prefix indicating
which hash was used, so they are 'transportable' to different machines.
> If the salted encrypted passwords in the shadow file are transportable
> between machines then it looks feasible.
They are, at least as long as you are not trying to transport to a
circa 1995 vintage install.
>> Was also going to suggest this. If you have a fairly static setup (a
>> handful of machines, a handful of users, not much churn) then just
>> manually cloning the UID/GID's to the small number of machines password
>> files is likely the simplest way to go.
>
> I wouldn't clone entire files but just selected ids. For example, I
> might have
>
> uids 0 to 999 for local system use
> uids 1000 to 1999 for local users
> uids 2000 to 2999 for global users, usable on any machine on the network
>
> As for the updates I see getpwent and putpwent are designed to read and
> write such credentials.
>
>
https://man7.org/linux/man-pages/man3/getpwent.3.html
>
https://man7.org/linux/man-pages/man3/putpwent.3.html
>
> Unfortunately, the descriptions are vague and don't say they will work
> with shadow files.
If you want to write C code to do this (as opposed to a quick script)
then you'll want to look at shadow(3) as well.
> Nor do they say what to use to read and write group files.
This is why learning the local man command, instead of browsing html
versions, is good. "man -a -w group" returns
"/usr/man/man5/group.5.gz". "man group" opens this man page, which at
the bottom crossreferences to getgrent(3). "man getgrent" returns the
man page of the C library functions for handling group files.
>> Now, if James has a lot of churn (add/subtract users and/or machines on
>> a somewhat regular basis) then setting up something like NIS may be
>> warranted.
>>
>> But, in typical Usenet fashion, James also left out any details along
>> those lines for us to have any real idea of what he is dealing with.
>
> In this case I didn't want a specific solution but some ideas I could
> research further. Don't worry, though, questions which are more specific
> may be forthcoming. :-)
I didn't ask for a 'solition' -- I said you left out details of what
you wanted to do. I.e., how many machines total. How many different
users. How often do new users get added. How often do old users get
expired (removed). I.e., operational details.
You told us you had a NAS. You left out the other details above.
That's not enough info for us to reliably suggest reasonable routes of
attack.