Koozali.org: home of the SME Server

Changing user password through command line in ssh?

hackersoft

Changing user password through command line in ssh?
« on: November 17, 2006, 03:40:17 AM »
Is there a way to change user passwords from the shell instead of the website? For hundreds of users, it take time to change it using the /server-manager panels...

If there's a way to change/reset user passwords without affecting SME's functionality as a whole, that would be cool.

Thanks in advance!

Offline mmccarn

  • *
  • 2,656
  • +10/-0
Changing user password through command line in ssh?
« Reply #1 on: November 17, 2006, 07:49:58 AM »
You might want to install and use the Lazy Admin Tools.  Search for e-smith-lazy_admin_tools-0_9_1-0_noarch.rpm in SME7Contribs, or here's a direct link: e-smith-lazy_admin_tools-0_9_1-0_noarch.rpm

Here's a brief, untested set of installation instructions:

mkdir -p /root/lat
cd /root/lat
wget http://mirror.contribs.org/smeserver/contribs//jbennett/sme7/lat/smeserver-lazy_admin_tools-0.9.1-2.noarch.rpm
rpm -Uvh smeserver-lazy_admin_tools-0.9.1-2.noarch.rpm

Now if you run man lat-users and read through the docs you'll find:
Code: [Select]
lat-users -a -c "harry | Harry | Potter | Quidditch"

       Creates user 'harry' from the command line, with password 'Quidditch'.

(You aren't told, but if user "harry" already exists, his information is updated with the values you have specified).



I think you could also do it like this if you're brave (replace "password1", "password2", "password3" with your chosen passwords for "user1", "user2" and "user3":

pico -w /root/masspass.sh
Code: [Select]
echo password1 | passwd --stdin user1
echo password2 | passwd --stdin user2
echo password3 | passwd --stdin user3
sh /root/masspass.sh

hackersoft

Changing user password through command line in ssh?
« Reply #2 on: November 17, 2006, 11:12:59 AM »
Thanks for the info about lazy admin tools.
I did read the manual for lat but it seems that my
tired eyes didn't notice it will update the password or user
information if the user already exists....

Again, thanks!

Offline mmccarn

  • *
  • 2,656
  • +10/-0
Changing user password through command line in ssh?
« Reply #3 on: November 17, 2006, 03:02:19 PM »
Quote from: "hackersoft"
my tired eyes didn't notice it will update the password or user information if the user already exists

I couldn't find it in the manual either so I tried it on an existing test user and got a very polite message about 'updating existing user'...

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Changing user password through command line in ssh?
« Reply #4 on: November 18, 2006, 12:16:14 AM »
Quote from: "mmccarn"

pico -w /root/masspass.sh
Code: [Select]
echo password1 | passwd --stdin user1
echo password2 | passwd --stdin user2
echo password3 | passwd --stdin user3
sh /root/masspass.sh


That will break samba/PPTP passwords - the users will still have their old samba/PPTP passwords.

Offline mmccarn

  • *
  • 2,656
  • +10/-0
Changing user password through command line in ssh?
« Reply #5 on: November 18, 2006, 05:59:56 PM »
Quote from: "CharlieBrady"
That will break samba/PPTP passwords - the users will still have their old samba/PPTP passwords.

Thanks!

Offline arnoldob

  • *
  • 183
  • +0/-0
Changing user password through command line in ssh?
« Reply #6 on: November 18, 2006, 07:48:54 PM »
Is there some db configuratrion command that will allow root to change a user password from a remote SSH connection?
Tampa, FL USA

Offline mmccarn

  • *
  • 2,656
  • +10/-0
Changing user password through command line in ssh?
« Reply #7 on: November 18, 2006, 08:00:11 PM »
Here are at least 3 options:

1. Install the 'Lazy Admin Tools' (see above)

2. Connect with ssh or putty and run 'su admin', then pick menu option 6 to run 'server-manager' in text mode (somewhat frustrating!)

3. Use ssh or putty to tunnel port 443 to your sme server, then run server-manager locally, like this:

ssh <YourSMEServerName> -l root -C  -L 443:127.0.0.1:443
-or-
putty <YourSMEServerName> -C -L 443:127.0.0.1:443

then, from your local workstation, open Firefox and browse to:

https://localhost/server-manager

(you should get the server-manager screen just as if you were on the server's local network...)

Offline arnoldob

  • *
  • 183
  • +0/-0
Changing user password through command line in ssh?
« Reply #8 on: November 18, 2006, 08:16:24 PM »
Thanks for the quick reply. It looks like I wasn't specfic enough. I'm remote, I have putty setup to connect to root with RSA keys, but I can't connect to admin because I never generated the RSA keys for admin login.

I have a user who needs their password reset, so I was just looking for a root command that would work correctly for SME. I don't think the standard linux password command would do because of SME's oddities. Ithought maybe it might be:
db configuration xxx xxx xxx
but I don't know the syntax. It also ocurred to me that their might be a system event commmand that would do the trick.
Tampa, FL USA

Offline mmccarn

  • *
  • 2,656
  • +10/-0
Changing user password through command line in ssh?
« Reply #9 on: November 18, 2006, 08:22:56 PM »
I don't think there is any system event or db command for passwords.

There's no reason you can't use either option 2 or 3 from my last post with putty to a root account.  If you can't  start putty from the command line, you can specify the tunnel manually once putty is running by:

- click on the top left corner of your putty window
- select 'change settings'
- click on 'SSH' on the left and select 'compression' on the right
- click on 'tunnels' on the left
-- enter 443 in the 'Source Port' field
-- enter 127.0.0.1:443 in the 'Destination' field
-- leave all else unchanged ('Local', 'Auto' selected)
- click on 'Add'
- click on 'Apply'

now login to server-manager at https://localhost/server-manager

Offline arnoldob

  • *
  • 183
  • +0/-0
Changing user password through command line in ssh?
« Reply #10 on: November 18, 2006, 08:46:50 PM »
Doh! I seemed to have missed the whole "su admin" thing.
I got it changed, thanks for your help.
Tampa, FL USA