Setting up users and securing my server.
by
- Add myself a user
- Automatically create me ssh key
- Prevent root from logging in via ssh
- Prevent users from logging in other than with a key.
- It would be nice to be able to email me my key since I don't run puppet on my mac, though I may be convinced to go down that route if it proves too difficult.
Create the users module
We're going to do this pretty much straight out of the puppet best practice guide, the first thing we'll do is flesh out our users module.# cd /etc/puppet
# mkdir -p modules/user/manifests
modules/user/manifests/virtual.pp
# virtual.pp
#
# People accounts of interest as virtual resources
class user::virtual {
@user { "andrewmccall":
ensure => "present",
uid => "1001",
gid => "1001",
comment => "Andrew McCall",
home => "/home/andrewmccall",
shell => "/bin/bash",
}
}
modules/users/manifests/unixadmins.pp
# unixadmins.pp
#
# Realize the members of the Unix team and include any contractors
class user::unixadmins inherits user::virtual {
# Realize our team members
realize(
User["andrewmccall"]
)
}
modules/users/manifests/init.pp
import "*"
class user {
include user::virtual, user::unixadmins
}
manifests/site.pp
# site.pp
import "nodes"
Exec { path => "/usr/bin:/usr/sbin/:/bin:/sbin" }
manifests/site.pp
# node.pp
node default {
include sudo, user
}
# puppet -v --modulepath=/etc/puppet/modules /etc/puppet/manifests/site.pp
info: Autoloaded module sudo
info: Autoloaded module user
info: Applying configuration version '1281041300'
err: //user::virtual/User[andrewmccall]/ensure: change from absent to present failed: Could not create user andrewmccall: Execution of '/usr/sbin/useradd -u 1001 -g 1001 -s /bin/bash -c Andrew McCall -d /home/andrewmccall andrewmccall' returned 6: useradd: group '1001' does not exist
Subscribe via RSS