How to add a new user to Webmin from shell via (bash,sh)

Thursday, 8th July 2010

You might search for a way to add a new user to your Webmin without bothering using the Webmin user interface or you simply prefer using shell for adding the new user to Webmin just like I do.

1.In order to manually add a new user to webmin you will have to edit webmin’s /etc/webmin/miniserv.users which is the default miniserv.uesrs location in many Linux distributions, however in FreeBSD or other BSDs the miniserv.users file location would probably be /usr/share/etc/webmin/ or /usr/share/webmin/etc , anyways if you are adding the new user manually open the file and copy paste the line:
root:12ZWQKVLjpihs:0
to a new line, where you will have to modify the line substituting root with newusername , like so:

newusername:12ZWQKVLjpihs:0

Afterwards you will have to also edit the file /etc/webmin/webmin.acl and likewise copy paste the definitions allowing access to all recources to the root user which in webmin.acl by default are:

root: acl adsl-client apache at backup-config bacula-backup bandwidth bind8 burner cfengine change-user cluster-copy cluster-cron cluster-passwd cluster-shell cluster-software cluster-useradmin cluster-usermin cluster-webmin cpan cron custom dfsadmin dhcpd dnsadmin dovecot exim exports fdisk fetchmail file filter firewall frox fsdump grub heartbeat htaccess-htpasswd idmapd inetd init inittab ipfilter ipfw ipsec jabber krb5 ldap-client ldap-server ldap-useradmin lilo logrotate lpadmin lvm mailboxes mailcap majordomo man mon mount mysql net nis openslp package-updates pam pap passwd phpini postfix postgresql ppp-client pptp-client pptp-server procmail proc proftpd pserver qmailadmin quota raid samba sarg sendmail sentry servers shell shorewall smart-status smf software spam squid sshd status stunnel syslog syslog-ng system-status tcpwrappers telnet time tunnel updown useradmin usermin vgetty webalizer webminlog webmin wuftpd xinetd

In my case I wanted to add to the newly created newuser only acl privileges for user crontab modification and htaccess-passwd creation thus I have included in the webmin.acl file only:

newuser: cron webmin htaccess-passwd

You will also be required to change the new user webmin password to some password of your choice, to attain that in Debian Linux execute:

debian:~# /usr/share/webmin/changepass.pl /etc/webmin newusername type_your_password

On Fedora and other RPM (Redhat based linux distros) the webmin changepass.pl user password change script is located in /usr/libexec/webmin/changepass.pl therefore if you’re about to change the password for the new user on Fedora and alike, type:

fedora:~# /usr/libexec/webmin/changepass.pl /etc/webmin/ newusername your_password

In the above change password exapmles you need to substitute newusername with the user chosen to be the new username as explained earlier in the post.
Finally in order for the newly added user with the respectively configured permissions to start working in Webmin, you will have to reload the webmdaemon. In most linux distributions (including Debian), to restart webmin you will have to issue:

linux-shell:~# /etc/init.d/webmin restart

However if you’re looking for a bit more automated way instead of manually editting the miniserv.users and webmin.acl files.
2. Herein is a tiny shell script I’ve written which facilitates the new webmin user creation under a console / terminal / shell

I have written webmin-new-user.sh just for fun, and it could be greatly improved, so don’t expect too much from it it doesn’t do any checks on the input given to the script, so be sure to pass a correct input as required from the dialogs in order to be able to use the script to add new users to your webmin from bash or any other unix shell.
The script is written to work with Debian on Fedora and other rpm based distributions as well as BSD a minor tunings within the script might be necessary to make the script work.
Please leave feedback on the script if it is of any use to you 🙂

Share this on:

Download PDFDownload PDF

Tags: ,

17 Responses to “How to add a new user to Webmin from shell via (bash,sh)”

  1. Tsymyn says:
    Google Chrome 6.0.472.63 Google Chrome 6.0.472.63 Windows 7 Windows 7
    Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3

    Thanks! This saved my butt when webmin suddenly stopped taking the password of the only allowed user.

    View CommentView Comment
  2. akula07 says:
    Google Chrome 13.0.782.215 Google Chrome 13.0.782.215 Mac OS X 10.6.8 Mac OS X 10.6.8
    Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.215 Safari/535.1

    sudo /usr/libexec/webmin/changepass.pl /etc/webmin root yourpassword

    View CommentView Comment
  3. chris says:
    Chromium 13.0.782.215 Chromium 13.0.782.215 Ubuntu 11.10 x64 Ubuntu 11.10 x64
    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Ubuntu/11.10 Chromium/13.0.782.215 Chrome/13.0.782.215 Safari/535.1

    Thanks loads, hip0! I was stuck on the login screen with little idea of how to fix things in the cli.

    View CommentView Comment
  4. JP says:
    Google Chrome 12.0.742.100 Google Chrome 12.0.742.100 Windows Vista x64 Edition Windows Vista x64 Edition
    Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.100 Safari/534.30

    I was able to edit the users and acl files, but I could not find changepass.pl. I did fine passwd in the root of the webmin directory and it let me change the root password, but would not recognize the new user “admin” that I had created. I am using the Amazon Linux AMI on EC2.

    Any ideas?

    View CommentView Comment
    • admin says:
      Epiphany 2.30.6 Epiphany 2.30.6 Debian GNU/Linux x64 Debian GNU/Linux x64
      Mozilla/5.0 (X11; U; Linux x86_64; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/531.2+ Debian/squeeze (2.30.6-1) Epiphany/2.30.6

      Do you get some errors in the webmin log files? /var/log/webmin* or somewhere, I’m not sure were the Amazon Linux AMI on EC2’s webmin package’s log is.
      Also is the webmin supported by EC2 platform? Maybe there is some issue like that, also check if you have copy pasted the file with ACLs if you have used windows it might be something wrong with the End of file extra characters added by the Windows?

      best!
      Georgi

      View CommentView Comment
      • JP says:
        Google Chrome 12.0.742.100 Google Chrome 12.0.742.100 Windows Vista x64 Edition Windows Vista x64 Edition
        Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.100 Safari/534.30

        I was able to reset the root user password and login to webmin, but still want to setup a separate account.

        Since it is running, I would say it is supported. I do not have a folder webmin in the var/log path.

        I will check the copy but I didn’t see anything in there.

        View CommentView Comment
    • admin says:
      Epiphany 2.30.6 Epiphany 2.30.6 Debian GNU/Linux x64 Debian GNU/Linux x64
      Mozilla/5.0 (X11; U; Linux x86_64; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/531.2+ Debian/squeeze (2.30.6-1) Epiphany/2.30.6

      Hi
      Sorry, I’ve red your post to quickly today and I was too busy, here is changepass.pl from debian Squeeze
      http://www.pc-freak.net/files/changepass.pl
      Download it and try to use it

      best!
      Georgi

      View CommentView Comment
  5. James Morgan says:
    Firefox 7.0.1 Firefox 7.0.1 Windows 7 x64 Edition Windows 7 x64 Edition
    Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1

    Great article, easy to follow. I had WebMin up on an Amazon EC2 server in less than an hour.

    View CommentView Comment
  6. web design liverpool says:
    Google Chrome 17.0.963.79 Google Chrome 17.0.963.79 Windows 7 x64 Edition Windows 7 x64 Edition
    Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11

    really useful article, saved me loads of time, thanks

    View CommentView Comment
  7. Diego says:
    Firefox 14.0.1 Firefox 14.0.1 Windows 7 x64 Edition Windows 7 x64 Edition
    Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1

    Thanks man! You saved my butt once the root password is not an option for me.

    View CommentView Comment
  8. Eric Boucher says:
    Google Chrome 25.0.1364.172 Google Chrome 25.0.1364.172 Windows XP Windows XP
    Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22

    I used your tips to clone a user account via scripting, it really helped me, thanks. In the process, I discovered other important files that you may also modify:

    /etc/webmin/config ==> Contains usernames’ real names

    /etc/webmin/.acl ==> Global Webmin ACLs for

    /etc/webmin/custom/.acl ==> Custom commands for

    View CommentView Comment
  9. Urgen says:
    Firefox 21.0 Firefox 21.0 Windows 7 Windows 7
    Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0

    hi thanks, man could you let me know how to allow particular ip addressess for example 192.168.0.33,192.168.0.55  to visit the particular website (eg. facebook.com,youtube.com )   and block the rest of network (192.168.0.0/24)

    View CommentView Comment
  10. Victorina Perniciaro says:
    Opera 8.50 8.50 Opera 8.50 8.50 Windows XP Windows XP
    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 8.50

    Really enjoyed this update, can I set it up so I get an email whenever you make a fresh update?

    View CommentView Comment

Leave a Reply

CommentLuv badge