NSLU2-Linux
view · edit · print · history

HowTo.ChangePasswordsFromTheCommandLine History

Hide minor edits - Show changes to markup

February 10, 2009, at 02:00 AM by dbh -- note about 6.10 possible persistent file (at bottom)
Changed lines 257-258 from:

...it seems that changes in /share/flash/data/etc/passwd are persistent. (If I'm not totally mixing off something right now.) -GreenBear?, 26.08.2008

to:

...it seems that changes in /share/flash/data/etc/passwd are persistent. (If I'm not totally mixing off something right now.) -GreenBear?, 26.08.2008 On my machine, this is a link to /share/flash/conf/passwd -dbh 2009-02-09

August 26, 2008, at 05:34 PM by GreenBear --
Changed line 257 from:

...it seems that changes in /share/flash/data/etc/passwd are persistent. (If I'm not totally confused, right now) -GreenBear?, 26.08.2008

to:

...it seems that changes in /share/flash/data/etc/passwd are persistent. (If I'm not totally mixing off something right now.) -GreenBear?, 26.08.2008

August 26, 2008, at 05:30 PM by GreenBear -- Different behavior uNSLUng 6.10 beta
Added lines 254-257:

On firmware version V2.3R63-uNSLUng-6.10-beta...

...it seems that changes in /share/flash/data/etc/passwd are persistent. (If I'm not totally confused, right now) -GreenBear?, 26.08.2008

November 07, 2007, at 11:13 PM by Jim DeLaHunt -- mention that /bin/unsling offers to change root password. Talk about editing /password on conf partition.
Changed lines 1-2 from:

So, you've got Unslung installed and now you'd like to change the root password to something of your own choosing. You change the password with the passwd utility, but when the NSLU2 reboots, it goes back to the default root passwd and you're left scratching your head wondering what went wrong.

to:

So, you've got Unslung installed and now you'd like to change the root password to something of your own choosing. Well, the /bin/unsling script from InstallUnslungFirmware will ask you for a new root password when you first unsling a disk. But what if you want to change the root password later, or change other passwords than root?

You change the password with the passwd utility, but when the NSLU2 reboots, it goes back to the default root passwd and you're left scratching your head wondering what went wrong.

Overview

Added line 24:

Scripts to simplify the job

Added lines 249-253:

Alternative: edit the persistent passwd file directly

There's more than one way to skin a cat. You can also access the NSLU2 disk from Linux, and edit the file in the "conf" partition named /passwd. This is the file which on the NSLU2 becomes /share/hdd/conf/passwd. It is a normal Linux /etc/passwd format file. The simplest operation is to copy the encrypted password from one user's entry to another.

January 24, 2007, at 04:05 AM by sudogeek --
Added line 212:
January 24, 2007, at 04:03 AM by sudogeek -- Fix using rc scripts
Changed lines 205-242 from:

for me it works, mike 22.06.06

to:

for me it works, mike 22.06.06


An alternative:

The boot sequence for 6.8 is rc.sysinit -> rc.1, which calls rc.reset_usrgrpshare. rc.reset_usrgrpshare calls /usr/sbin/reset_ugs which replaces the /etc/passwd file with one from memory.

rc.reset_usrgrpshare is:

(:table border=0 width=100% bgcolor=#f0f8ff:) (:cell:)

 
#!/bin/sh

if ( [ -f /unslung/rc.reset_usrgrpshare ] && . /unslung/rc.reset_usrgrpshare ) ; then return 0 ; fi

/usr/sbin/reset_ugs;
 

(:tableend:)

The problem can be fixed by:

1. Copy /etc/passwd to /opt/etc/passwd (which will not be overwritten). Remember to do this after any changes to passwords or users or 'cp /etc/passwd /opt/etc/passwd' can be added to rc.reboot and rc.halt.

2. Create /unslung/rc.reset_usrgrpshare like so:

(:table border=0 width=100% bgcolor=#f0f8ff:) (:cell:)

 
#!/bin/sh

/usr/sbin/reset_ugs

cp /opt/etc/passwd /etc/passwd;
 

(:tableend:)

October 03, 2006, at 07:39 PM by TimHughes -- fixed dodgy find command cd /; find -name...
Changed line 62 from:
 cd /;find -name .htpasswd
to:
 find / -name .htpasswd
June 05, 2006, at 07:28 PM by mike -- it works in 6.8
Changed lines 203-205 from:

Question: Is the script above still true for the Unslung 6.8?

to:

Question: Is the script above still true for the Unslung 6.8?

for me it works, mike 22.06.06

April 17, 2006, at 12:18 PM by StormLogiX --
Changed lines 202-203 from:

Thanks to everyone for their previous efforts.

to:

Question: Is the script above still true for the Unslung 6.8?

December 08, 2005, at 06:06 AM by tlhackque -- Add a more intelligent script
Changed lines 74-202 from:

Thanks to tman, rwhitby, barabasy69 and jncharli for previous efforts.

to:

There are generally 3 disks to worry about

Too many files, not enough neurons for me to keep it straight...

Here is a more intelligent script. This one will:

  • Preserve the symbolic link
  • Update all known copies of the passwd file
  • Handle any number of arguments for the passwd command
  • Update all secondary files without running the passwd command. Useful if you edit /etc/passwd to change a shell.
  • Handle errors if the passwd command fails

To use, install as /opt/bin/spasswd (chmod +x, of course).

/opt/bin/spasswd --help will provide usage.

If someone who knows the current boot flow wants to resolve the open issue - re-generating the symlink based on the boot device if /etc/passwd starts out as a regular file - please do. (And let me know.)

This seems to work on V5.5-beta.

Read and obey the previous cautions, and enjoy.

--tlhackque

(:table border=0 width=100% bgcolor=#f0f8ff:) (:cell:)

 
#!/bin/sh
#
# /bin/spasswd - manage /etc/passwd and its aliases
#
# tlhackque
#
# Parse command switches.  Musn't conflict with /usr/bin/passwd.
#
if [ "($1)" = '(--verbose)' ]; then
   VERBOSE=y
   shift
else
   VERBOSE=
fi
#
# Determine if /etc/passwd starts out as a symlink
#
if [ -L /etc/passwd ]; then
  INITIALPW=`ls -l /etc/passwd | sed -e 's|.*/etc/passwd -> \(/share/.*/conf/passwd\)$|\1|'`
  if [ "$VERBOSE" != '' ]; then echo "/etc/passwd -> $INITIALPW" ; fi
else
  INITIALPW=/etc/passwd
fi
#
if [ "($1)" != "(--refresh)" ]; then
  if [ "($1)" = "(--help)" ]; then
    cat <<EOF
Usage: $0 [--verbose] passwd_command_arguments
       $0 [--verbose] --refresh
       $0 --help

If --verbose is present, verbose output is produced for
reassurance (or debug).

The first format executes the /usr/bin/passwd command with
the specified arguments (if any).  If the command succeeds,
it then locates the other copies of the /etc/passwd file
and updates them by copying the new /etc/passwd file over
them.

The second format refreshes the copies, but does not
execute /usr/bin/passwd.  Use this after any manual
edits to /etc/passwd.  Be sure to use an editor that
preserves symbolic links, or edit the target!

The third format displays this message.

Issues:
  Perhaps /etc/passwd should be set to the appropriate
  symbolic link if it starts out as a regular file.
EOF
    exit
  else
    /usr/bin/passwd $* || exit
   # /etc/passwd has been updated, and probably is not a symlink.
  fi
fi
#
# /etc/passwd may be a symlink to the real file
#
if [ -L /etc/passwd ]; then
  ACTIVEPW=`ls -l /etc/passwd | sed -e 's|.*/etc/passwd -> \(/share/.*/conf/passwd\)$|\1|'`
else
  ACTIVEPW=/etc/passwd
fi
#
if [ "$VERBOSE" != '' ]; then echo "Updated $ACTIVEPW" ; fi
#
# Used when booting from disk 1
#
if [ -n "`mount | grep /share/hdd/conf`" ]; then
  if [ "$ACTIVEPW" != "/share/hdd/conf/passwd" ]; then
     cp /etc/passwd /share/hdd/conf/passwd
     if [ "$VERBOSE" != '' ]; then echo "Updated /share/hdd/conf/passwd" ; fi
  fi
fi
# Used when booting from disk 2
if [ -n "`mount | grep /share/flash/conf`" ]; then
  if [ "$ACTIVEPW" != "/share/flash/conf/passwd" ]; then
     cp /etc/passwd /share/flash/conf/passwd
     if [ "$VERBOSE" != '' ]; then echo "Updated /share/flash/conf/passwd" ; fi
  fi
fi
# Used when no disk present -- cat used because flash FS
# doesn't like cp
if [ "$ACTIVEPW" != "/usr/local/passwd" ]; then
   cat /etc/passwd >/usr/local/passwd
   if [ "$VERBOSE" != '' ]; then echo "Updated /usr/local/passwd" ; fi
fi
#
# If the initial /etc/passwd was a symlink, restore it.
if [ "$INITIALPW" != "/etc/passwd" ]; then
   ln -sf $INITIALPW /etc/passwd
   if [ "$VERBOSE" != '' ]; then echo "Re-linked /etc/passwd -> $INITIALPW" ; fi
fi
# EOF
 

(:tableend:)

Thanks to everyone for their previous efforts.

November 04, 2005, at 04:17 PM by tallemd -- added htpasswd bits
Changed lines 54-74 from:

Thanks to rwhitby, barabasy69 and jncharli for previous efforts.

to:

To change the web admin password from the command prompt try htpasswd. http://www.acme.com/software/thttpd/htpasswd_man.html

Here is the command to find the .htpasswd files to work with. (:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

 cd /;find -name .htpasswd

(:tableend:) Here is the command to edit the admin of a given file. (:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

 htpasswd -c /dir/.htpasswd admin #where dir is the directory found with find

(:tableend:)

My firmware doesn't include htpasswd so i can't test it. A quick fix is to edit a known working file and copy its encrypted password or whole file, however the key changes so this might not work.

Thanks to tman, rwhitby, barabasy69 and jncharli for previous efforts.

August 22, 2005, at 08:18 PM by tman --
Changed lines 10-11 from:

To do this for a slug using an unslung disk plugged into USB port 1, run these commands:

to:

To do this for a slug using an Unslung disk plugged into USB port 1, run these commands:

Changed lines 15-16 from:

To do this for a slug using an unslung disk plugged into USB port 2, run these commands:

to:

To do this for a slug using an Unslung disk plugged into USB port 2, run these commands:

Deleted lines 41-42:

See also FAQ nr 7.

June 21, 2005, at 07:50 PM by RobHam --
Changed line 30 from:
to:
Added line 33:
Added line 36:
June 21, 2005, at 05:41 PM by RobHam -- Added method for USB port 2
Changed lines 12-14 from:
  1. passwd
  2. cp /etc/passwd /share/hdd/conf/passwd
to:
  1. passwd
  2. cp /etc/passwd /share/hdd/conf/passwd

To do this for a slug using an unslung disk plugged into USB port 2, run these commands:

  1. passwd
  2. cp /etc/passwd /share/flash/conf/passwd

Changed lines 26-32 from:
 #!/bin/sh
 # 
 # slugpasswd - change password on NSLU2 after an unslung disk is attached

 passwd $1
 cp /etc/passwd /share/hdd/conf/passwd 
 cp /etc/passwd /usr/local/passwd 
to:
 
#!/bin/sh
# 
# slugpasswd - change password on NSLU2 after an unslung disk is attached

# change password 
passwd $1
# copy to unslung disk in port 1
cp /etc/passwd /share/hdd/conf/passwd
# Optionally change the /usr/local copy (not recommended for inexperienced users)
cp /etc/passwd /usr/local/passwd
 
June 21, 2005, at 02:00 AM by tman --
Changed lines 1-4 from:

So, you've got Unslung installed and now you'd like to change the root password to something of your own choosing. You change the password with the passwd utility, but when the NSLU reboots, it goes back to the default root passwd and you're left scratching your head wondering what went wrong.

The problem here is that the actual passwd file for the NSLU is kept in /share/hdd/conf/passwd and /usr/local/passwd. When the NSLU boots, whatever file is located at /etc/passwd is overwritten with a symlink to either /share/hdd/conf/passwd (when an unslung disk is attached) or /usr/local/passwd (when not unslung or no disk present).

to:

So, you've got Unslung installed and now you'd like to change the root password to something of your own choosing. You change the password with the passwd utility, but when the NSLU2 reboots, it goes back to the default root passwd and you're left scratching your head wondering what went wrong.

The problem here is that the actual passwd file for the NSLU2 is kept in /share/hdd/conf/passwd and /usr/local/passwd. When the NSLU2 boots, whatever file is located at /etc/passwd is overwritten with a symlink to either /share/hdd/conf/passwd (when an unslung disk is attached) or /usr/local/passwd (when not unslung or no disk present).

Added line 6:
Changed lines 10-13 from:

To do this for a slug using an unslung disk plugged into usb port 1, run these commands:

  • passwd
  • cp /etc/passwd /share/hdd/conf/passwd
to:

To do this for a slug using an unslung disk plugged into USB port 1, run these commands:

  1. passwd
  2. cp /etc/passwd /share/hdd/conf/passwd
Added lines 16-18:

(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

Changed lines 26-27 from:
to:

(:tableend:)

Added line 31:
Added lines 37-38:

(:table border=0 width=100% bgcolor=#eeffee:) (:cell:)

Changed lines 40-41 from:

Thanks to rwhitby, barabasy69 and jncharli for previous efforts.

to:

(:tableend:)

Thanks to rwhitby, barabasy69 and jncharli for previous efforts.

June 20, 2005, at 07:57 PM by ov2k -- formatting
Changed lines 6-14 from:

1. run passwd to change the password and create a new /etc/passwd file 2. copy the new file at /etc/passwd into the appropriate persistent file

To do this for a slug using an unslung disk plugged into usb port 1:

  1. passwd
  2. cp /etc/passwd /share/hdd/conf/passwd
to:
  1. run passwd to change the password and create a new /etc/passwd file
  2. copy the new file at /etc/passwd into the appropriate persistent file

To do this for a slug using an unslung disk plugged into usb port 1, run these commands:

  • passwd
  • cp /etc/passwd /share/hdd/conf/passwd
Deleted line 13:
Changed lines 25-27 from:

1. The passwd file is valid. An invalid file can lock you out of the slug. 2. You are copying into the appropriate location. There are generally 3 disks to worry about, the internal flash, USB port 1, and USB port 2.

to:
  1. The passwd file is valid. An invalid file can lock you out of the slug.
  2. You are copying into the appropriate location. There are generally 3 disks to worry about, the internal flash, USB port 1, and USB port 2.
June 20, 2005, at 07:53 PM by ov2k -- clarifying the /etc/passwd symlink
Changed lines 1-9 from:

So, you've got Unslung installed and now you'd like to change the root password to something of your own choosing. You change the password with the passwd utility, but when the NSLU reboots, it goes back to the default root passwd and you're left scratching your head wondering what went wrong.

The problem here is that the passwd file for the NSLU is kept in /etc/passwd, /usr/local/passwd and /share/hdd/conf/passwd. When the NSLU boots, /etc/passwd is overwritten at boot from either /usr/local/passwd (when not unslung or no disk present), or /share/hdd/conf/passwd (when an unslung disk is attached).

When the passwd utility is used to change your password, /etc/passwd is overwritten but not the others. In order to change your password from the command line you need to do the following (example is for when using an unslung disk plugged into usb port 1):

  1. passwd (change the password)
  2. copy /etc/passwd over /share/hdd/conf/passwd
to:

So, you've got Unslung installed and now you'd like to change the root password to something of your own choosing. You change the password with the passwd utility, but when the NSLU reboots, it goes back to the default root passwd and you're left scratching your head wondering what went wrong.

The problem here is that the actual passwd file for the NSLU is kept in /share/hdd/conf/passwd and /usr/local/passwd. When the NSLU boots, whatever file is located at /etc/passwd is overwritten with a symlink to either /share/hdd/conf/passwd (when an unslung disk is attached) or /usr/local/passwd (when not unslung or no disk present).

When the passwd utility is used to change your password, /etc/passwd is overwritten with a good passwd file but not the others, and so the changes do not persist after a reboot. In order to change your password from the command line you need to do 2 things:

1. run passwd to change the password and create a new /etc/passwd file 2. copy the new file at /etc/passwd into the appropriate persistent file

To do this for a slug using an unslung disk plugged into usb port 1:

  1. passwd
  2. cp /etc/passwd /share/hdd/conf/passwd
Changed line 17 from:
 #!/bin/bash
to:
 #!/bin/sh
Changed lines 27-30 from:

Note: If you are using an unslung disk, there are a number of steps to perform before this procedure can be followed. You will first have to boot with the disk detached, enable telnet from the web admin, login using telnet, re-attach the disk, then wait for it to mount. This is the same series of steps used to unsling the disk after the firmware is installed, listed in the 'UNSLINGING' DETAILS section of the README file that accompanies the Unslung firmware. (see http://www.toddcomp.com/NSLU2/README.txt)

This procedure works in version 3.18-beta. If this stops working in later versions, it may be helpful to search for all locations of passwd:

to:

When you do this, be absolutely sure about 2 things: 1. The passwd file is valid. An invalid file can lock you out of the slug. 2. You are copying into the appropriate location. There are generally 3 disks to worry about, the internal flash, USB port 1, and USB port 2.

This procedure works in version 5.5-beta. If this stops working in later versions, it may be helpful to search for all locations of passwd:

May 22, 2005, at 08:26 PM by Chadical -- added cp to /usr/local/passwd
Changed lines 18-19 from:
to:
 cp /etc/passwd /usr/local/passwd 
May 13, 2005, at 11:31 AM by roel --
Changed lines 5-6 from:

When the passwd utility is used to change your password, /etc/passwd is overwritten but not the others. In order to change your password from the command line you need to do the following (example is for when using an unslung disk):

to:

When the passwd utility is used to change your password, /etc/passwd is overwritten but not the others. In order to change your password from the command line you need to do the following (example is for when using an unslung disk plugged into usb port 1):

Changed lines 19-20 from:
to:

See also FAQ nr 7.

April 10, 2005, at 08:50 AM by MinorRoadsKill --
Deleted line 8:
  1. create a symlink /etc/passwd to /share/hdd/conf/passwd
Changed line 14 from:
 # slugpasswd - change password on NSLU2 and keep /etc/passwd symlink in order
to:
 # slugpasswd - change password on NSLU2 after an unslung disk is attached
Deleted line 17:
 ln -sf /share/hdd/conf/passwd /etc/passwd
Deleted line 18:

Restoring the symlink is not required to make the password 'stick', but creating it makes sense from the principle of keeping only 1 copy of any information.

Changed lines 20-22 from:

Note: I don't know whether /etc/passwd is originally a symlink or a file (seems to depend upon the unslung version), but in either case, this works in current 3.18-beta. If this stops working in later versions, it may be helpful to search for all locations of passwd:

to:

Note: If you are using an unslung disk, there are a number of steps to perform before this procedure can be followed. You will first have to boot with the disk detached, enable telnet from the web admin, login using telnet, re-attach the disk, then wait for it to mount. This is the same series of steps used to unsling the disk after the firmware is installed, listed in the 'UNSLINGING' DETAILS section of the README file that accompanies the Unslung firmware. (see http://www.toddcomp.com/NSLU2/README.txt)

This procedure works in version 3.18-beta. If this stops working in later versions, it may be helpful to search for all locations of passwd:

Changed lines 26-63 from:

Thanks to rwhitby and barabasy69 for previous efforts.


Added by jncharli on 2005 March the 29th

As many users, I experienced some troubles to change the telnet root password when a disk is attached. As an example, the procedure above doesn't work...

Here follows the procedure I found, tested with V2.3R25-uNSLUng-standard-3.18-beta. It supposes that you have installed this release of Unslung.

  • Boot your NSLU2 with *NO* disk attached
  • Enable Telnet through http://192.168.192.50/Management/telnet.cgi, using default username/password (admin/admin), and clicking "Enable Telnet" if required
     (change 192.168.192.50 by the IP address of your NSLU2)
  • Start a Telnet session (telnet 192.168.192.50) as root, using default password (uNSLUng)
     (change 192.168.192.50 by the IP address of your NSLU2)
  • Hot plug your disk into your NSLU2
  • Wait some minutes in order your disk to be automatically mounted
     As soon as the disk is mounted, the /etc/passwd file is overwritten by the passwd file stored on the mounted disk 
  • enter the following commands :
    • passwd
          enter twice your new password for root
  • cp /etc/passwd /share/hdd/conf/
          It's useless to create any link
  • reboot

That's it !

To check it runs, after the reboot :

  • Keep the disk plugged in the NSLU2
  • Enable Telnet through http://192.168.192.50/Management/telnet.cgi, using your customized username/password, and clicking "Enable Telnet" if required
     (change 192.168.192.50 by the IP address of your NSLU2)
  • Start a Telnet session (telnet 192.168.192.50) as root, using your newly changed password
     (change 192.168.192.50 by the IP address of your NSLU2)

It should run...

to:

Thanks to rwhitby, barabasy69 and jncharli for previous efforts.

March 29, 2005, at 10:15 PM by jncharli --
Changed lines 27-64 from:

Thanks to rwhitby and barabasy69 for previous efforts.

to:

Thanks to rwhitby and barabasy69 for previous efforts.


Added by jncharli on 2005 March the 29th

As many users, I experienced some troubles to change the telnet root password when a disk is attached. As an example, the procedure above doesn't work...

Here follows the procedure I found, tested with V2.3R25-uNSLUng-standard-3.18-beta. It supposes that you have installed this release of Unslung.

  • Boot your NSLU2 with *NO* disk attached
  • Enable Telnet through http://192.168.192.50/Management/telnet.cgi, using default username/password (admin/admin), and clicking "Enable Telnet" if required
     (change 192.168.192.50 by the IP address of your NSLU2)
  • Start a Telnet session (telnet 192.168.192.50) as root, using default password (uNSLUng)
     (change 192.168.192.50 by the IP address of your NSLU2)
  • Hot plug your disk into your NSLU2
  • Wait some minutes in order your disk to be automatically mounted
     As soon as the disk is mounted, the /etc/passwd file is overwritten by the passwd file stored on the mounted disk 
  • enter the following commands :
    • passwd
          enter twice your new password for root
  • cp /etc/passwd /share/hdd/conf/
          It's useless to create any link
  • reboot

That's it !

To check it runs, after the reboot :

  • Keep the disk plugged in the NSLU2
  • Enable Telnet through http://192.168.192.50/Management/telnet.cgi, using your customized username/password, and clicking "Enable Telnet" if required
     (change 192.168.192.50 by the IP address of your NSLU2)
  • Start a Telnet session (telnet 192.168.192.50) as root, using your newly changed password
     (change 192.168.192.50 by the IP address of your NSLU2)

It should run...

March 29, 2005, at 09:28 PM by MinorRoadsKill --
Changed lines 3-5 from:

The problem here is that the passwd file for the NSLU is kept in / and /etc/passwd is a symlink to /passwd. When you use the passwd utility to change your password, it removes the symlink in /etc/passwd and writes a new file. In order to change your password from the command line you need to do the following.

to:

The problem here is that the passwd file for the NSLU is kept in /etc/passwd, /usr/local/passwd and /share/hdd/conf/passwd. When the NSLU boots, /etc/passwd is overwritten at boot from either /usr/local/passwd (when not unslung or no disk present), or /share/hdd/conf/passwd (when an unslung disk is attached).

When the passwd utility is used to change your password, /etc/passwd is overwritten but not the others. In order to change your password from the command line you need to do the following (example is for when using an unslung disk):

Changed lines 8-10 from:
  1. copy /etc/passwd over /passwd
  2. delete /etc/passwd with rm (DO NOT do this if you're logged in as a user other than root and using sudo, since this will leave sudo non-functional, and you with no way to create the symlink. Instead, use the "ln -sf" syntax when creating a link in the next step.)
  3. create a symlink /etc/passwd to /passwd
to:
  1. copy /etc/passwd over /share/hdd/conf/passwd
  2. create a symlink /etc/passwd to /share/hdd/conf/passwd
Deleted line 12:
Changed lines 18-20 from:
 cp /etc/passwd /passwd 
 ln -sf /passwd /etc/passwd
to:
 cp /etc/passwd /share/hdd/conf/passwd 
 ln -sf /share/hdd/conf/passwd /etc/passwd
Changed lines 21-30 from:

Thanks to rwhitby for pointing me to the mailing list post[1] and barabasy69 for figuring this out in the first place. [1] http://groups.yahoo.com/group/nslu2-linux/message/1886


Update 03-Jan-2005
As of v3.17-beta, at least (and possibly earlier versions - I've been away for awhile), the /etc/passwd *is* a real file but it gets overwritten at boot by a copy of what's in /usr/local/passwd (The /passwd mentioned above appears to be gone now).
So when you make a change be sure to copy it over to /usr/local/passwd as well or your change will get undone on the next boot.

Note: I am running with no drives at all so this may not quite apply to a system with a drive attached. Someone with a drive care to test and elaborate? (Worst case if your changes aren't saving do a:

to:

Restoring the symlink is not required to make the password 'stick', but creating it makes sense from the principle of keeping only 1 copy of any information.

Added line 23:

Note: I don't know whether /etc/passwd is originally a symlink or a file (seems to depend upon the unslung version), but in either case, this works in current 3.18-beta. If this stops working in later versions, it may be helpful to search for all locations of passwd:

Changed lines 27-43 from:

...and see what shows up. :)

 #!/bin/sh
 # for unslung-v3.17-beta
 # slugpasswd - change password on NSLU2 and keep /etc/passwd symlink in order

 passwd $1
 cp /etc/passwd /share/hdd/conf/passwd 
 ln -sf /share/hdd/conf/passwd /etc/passwd

Update 24-Feb-2005
Maybe, if in doubt, you can run a command like that:

 for P in `find /share/hdd/conf -name passwd`; do ls -la $P; done
to:

Thanks to rwhitby and barabasy69 for previous efforts.

February 24, 2005, at 07:54 PM by kaste --
Added lines 48-52:

Update 24-Feb-2005
Maybe, if in doubt, you can run a command like that:

 for P in `find /share/hdd/conf -name passwd`; do ls -la $P; done
January 06, 2005, at 04:08 PM by krki --
Changed lines 37-47 from:

...and see what shows up. :)

to:

...and see what shows up. :)

 #!/bin/sh
 # for unslung-v3.17-beta
 # slugpasswd - change password on NSLU2 and keep /etc/passwd symlink in order

 passwd $1
 cp /etc/passwd /share/hdd/conf/passwd 
 ln -sf /share/hdd/conf/passwd /etc/passwd
January 03, 2005, at 08:45 AM by Lex Delani --
Changed lines 31-34 from:

Note: I am running with no drives at all so this may not quite apply to a system with a drive attached. Someone with a drive care to test and elaborate? (Worst case if your changes aren't saving do a:

find / -name 'passwd'
\\

to:

Note: I am running with no drives at all so this may not quite apply to a system with a drive attached. Someone with a drive care to test and elaborate? (Worst case if your changes aren't saving do a:

 find / -name 'passwd'
January 03, 2005, at 08:27 AM by itwerx --
Changed lines 26-32 from:

=============================== Update 03-Jan-2005 As of v3.17-beta, at least (and possibly earlier versions - I've been away for awhile), the /etc/passwd *is* a real file but it gets overwritten at boot by a copy of what's in /usr/local/passwd (The /passwd mentioned above appears to be gone now).

   So when you make a change be sure to copy it over to /usr/local/passwd as well or your change will get undone on the next boot.

Note: I am running with no drives at all so this may not quite apply to a system with a drive attached. Someone with a drive care to test and elaborate? (Worst case if your changes aren't saving do a:

   find / -name 'passwd'
to:

Update 03-Jan-2005
As of v3.17-beta, at least (and possibly earlier versions - I've been away for awhile), the /etc/passwd *is* a real file but it gets overwritten at boot by a copy of what's in /usr/local/passwd (The /passwd mentioned above appears to be gone now).
So when you make a change be sure to copy it over to /usr/local/passwd as well or your change will get undone on the next boot.

Note: I am running with no drives at all so this may not quite apply to a system with a drive attached. Someone with a drive care to test and elaborate? (Worst case if your changes aren't saving do a:

find / -name 'passwd'
\\

January 03, 2005, at 08:20 AM by itwerx --
Added line 23:

[1] http://groups.yahoo.com/group/nslu2-linux/message/1886

Changed lines 25-33 from:

[1] http://groups.yahoo.com/group/nslu2-linux/message/1886

to:

=============================== Update 03-Jan-2005 As of v3.17-beta, at least (and possibly earlier versions - I've been away for awhile), the /etc/passwd *is* a real file but it gets overwritten at boot by a copy of what's in /usr/local/passwd (The /passwd mentioned above appears to be gone now).

   So when you make a change be sure to copy it over to /usr/local/passwd as well or your change will get undone on the next boot.

Note: I am running with no drives at all so this may not quite apply to a system with a drive attached. Someone with a drive care to test and elaborate? (Worst case if your changes aren't saving do a:

   find / -name 'passwd'

...and see what shows up. :)

December 08, 2004, at 09:06 PM by polkadotninja --
Changed line 7 from:
  1. delete /etc/passwd
to:
  1. delete /etc/passwd with rm (DO NOT do this if you're logged in as a user other than root and using sudo, since this will leave sudo non-functional, and you with no way to create the symlink. Instead, use the "ln -sf" syntax when creating a link in the next step.)
October 10, 2004, at 02:45 AM by tman --
Changed lines 19-20 from:
 rm /etc/passwd 
 ln -s /passwd /etc/passwd
to:
 ln -sf /passwd /etc/passwd
October 09, 2004, at 01:33 PM by snrub --
Changed lines 13-15 from:

#!/bin/bash #

  1. slugpasswd - change password on NSLU2 and keep /etc/passwd symlink in order
to:
 #!/bin/bash
 # 
 # slugpasswd - change password on NSLU2 and keep /etc/passwd symlink in order

 passwd $1
 cp /etc/passwd /passwd 
 rm /etc/passwd 
 ln -s /passwd /etc/passwd
Deleted lines 21-24:

passwd $1 cp /etc/passwd /passwd rm /etc/passwd ln -s /passwd /etc/passwd

Added line 23:

Thanks to rwhitby for pointing me to the mailing list post[1] and barabasy69 for figuring this out in the first place.

Changed line 25 from:

Thanks to rwhitby for pointing me to the mail list posting[1] and barabasy69 for posting this info to the list in the first place.

to:

[1] http://groups.yahoo.com/group/nslu2-linux/message/1886

October 09, 2004, at 01:28 PM by snrub --
Changed lines 1-23 from:
to:

So, you've got Unslung installed and now you'd like to change the root password to something of your own choosing. You change the password with the passwd utility, but when the NSLU reboots, it goes back to the default root passwd and you're left scratching your head wondering what went wrong.

The problem here is that the passwd file for the NSLU is kept in / and /etc/passwd is a symlink to /passwd. When you use the passwd utility to change your password, it removes the symlink in /etc/passwd and writes a new file. In order to change your password from the command line you need to do the following.

  1. passwd (change the password)
  2. copy /etc/passwd over /passwd
  3. delete /etc/passwd
  4. create a symlink /etc/passwd to /passwd

Here's a little shell script to take care of all this for you.

#!/bin/bash #

  1. slugpasswd - change password on NSLU2 and keep /etc/passwd symlink in order

passwd $1 cp /etc/passwd /passwd rm /etc/passwd ln -s /passwd /etc/passwd

Thanks to rwhitby for pointing me to the mail list posting[1] and barabasy69 for posting this info to the list in the first place.

Page last modified on February 10, 2009, at 02:00 AM