Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Every time I setup a new server, I follow a series of steps on each server in order to get updates, set passwd, remove login via root user, customize a familiar environment (bashrc) and secure the server.

Is it possible to do all that using a script? The setup could include:

  1. distro upgrades and updates

    apt-get update

    apt-get upgrade

  2. adding users

    adduser deployer

    adduser deployer sudo

    mkdir /home/deployer/.ssh

    chmod 700 /home/deployer/.ssh

    touch /home/deployer/.ssh/authorization_keys

    deployer passwd

    su deployer

    cd to /home/deployer/.ssh/

    sudo chown deployer .ssh/

  3. Executing commands on local machine:



  4. logging back onto server:

    chmod 400 /home/deployer/.ssh/authorized_keys

    chown deployer:deployer /home/deployer -R

5..6...7.. Customizing bashrc, editing sshd_config, installing ufw & logwatch

share|improve this question
Look up config management systems like puppet or chef. – Sven Apr 3 '13 at 15:40
Or Ansible/Salt, for a different approach. – ceejayoz Apr 3 '13 at 15:41
have a look at kickstart installation -… – Gryphius Apr 3 '13 at 15:44
up vote 6 down vote accepted

Use a Kickstart or equivalent process to manage the build. Use a configuration management product like Puppet to deploy your settings.

You can also use a little bit of scripting magic to kick off the configuration management at the end of your build to make it a seamless experience.

My script sets a static IP, configures OSSEC and performs a couple puppet runs to sort out all the dependencies then runs a yum update (I'm primarily a CentOS user).

It's possible to cobble together other methods of getting the same results but I've found this to be the most flexible method I've worked with.

share|improve this answer
Cobbler all the things! – Scott Pack Apr 3 '13 at 17:07
@ScottPack - yeah, I looked Cobbler a while ago. I already Puppet, Kickstart and PXEBoot running for other things. Didn't see a reason to change. Didn't want to comment on a package I don't actively use. – Tim Brigham Apr 3 '13 at 18:26
Yeah, cobbler is nice, but really all it does is templatize your kickstarts so they can be programmatically built on the fly. Not much different from the erb templates in puppet. – Scott Pack Apr 4 '13 at 12:39

Kickstart/Jumpstart, Chef (including chef-solo), Puppet, Salt, shell-scripts, and higher-level scripting languages can all be used to solve this problem.

Honestly, it looks like you have a decent beginnings of a shell script. Start there, and if complexity ramps up, either iterate or look into a beefier product. Personally I've had good experience with Chef.

The key to automating all-the-things is to start small; you don't have to go whole-hog into automation. Pick one pain-point, and make that better. Pick another, repeat.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.