User Tools

Site Tools


scripts:addu

Setting up a secure samba share on your Ubuntu Linux box requires use of the terminal, and the knowledge of smbpasswd. If you've ever had trouble connecting your Windows boxes to your Ubuntu file shares, this may be of use to you.

addu creates the Linux user, and then gives them access to samba – automatically.

addu.sh
#!/bin/bash
# Add an account to Linux and add to samba automagically
# Created to speed up user creation on an Ubuntu Server,
# but could be used on any Linux platform for the same thing.
 
sudo echo Enter super-user password...
clear
 
echo 
echo Add a user to the server
echo
read -p "Username: "
 USERNAME="$REPLY"
read -p "Password: "
 PASSWORD="$REPLY"
echo
echo Adding user $USERNAME
 sudo useradd $USERNAME
echo Done.
echo
echo Setting password for $USERNAME
 (echo $PASSWORD; echo $PASSWORD ) | sudo passwd $USERNAME
echo
echo Adding $USERNAME to samba
 (echo $PASSWORD; echo $PASSWORD ) | sudo smbpasswd -s -a $USERNAME
echo
echo All done adding $USERNAME
scripts/addu.txt · Last modified: 2012/01/26 09:18 by import