StuRa:Server/FreeBSD
Dokumentation für den FreeBSD-Server
Sicherheit
FreeBSD audit
- faschistoides Logging von Systemcalls
- präventiv wirkungslos, aber in der post-mortem Analyse extrem hilfreich
- FreeBSD Kapitel 17. Security Event Auditing
- in /etc/rc.conf:
auditd_enable="YES"
- start auditd:
/etc/rc.d/auditd start
- in /etc/security/audit_control:
flags:lo,aa,ex
policy:cnt,argv
synchronize config: audit -s
- cronjob für die logs: /etc/crontab
"0 */12 * * * root /usr/sbin/audit -n"
Jails
Jails dienen der Virtualisierung von Betriebssysteminstanzen. Näheres dazu im FreeBSD Handbuch Kapitel 15 - Jails.
Anlegen eines Jails
cd /usr/src
- evtl. erst Sourcen installieren: sysinstall-> configure -> distributions
- evtl.
# make buildworld
- Jails liegen unter /home/jails/$JAILNAME
- System für jail bauen:
# make installworld DESTDIR=/home/jails/$JAILNAME
# make distribution DESTDIR=/home/jails/$JAILNAME
- device nodes ins jail packen
# mount -t devfs devfs /home/jails/$JAILNAME/dev
- resolv.conf kopieren:
cp host /etc/resolv.conf to /home/jails/$JAILNAME/etc/resolv.conf
- rc.conf editieren:
- jail_enable="YES"
- jail_list="$JAILNAME"
- ifconfig_bce0_alias0="$JAIL_IP netmask 255.255.255.0"
- jail_$JAILNAME_rootdir="/usr/home/jails/$JAILNAME"
- jail_$JAILNAME_hostname="$JAILNAME.stura.htw-dresden.de"
- jail_$JAILNAME_ip="$JAIL_IP"
- jail_$JAILNAME_devfs_enable="YES"
- jail_$JAILNAME_devfs_ruleset="devfs_rules_jail"
- jail starten:
/etc/rc.d/jail start
- Prozess im jail starten:
jexec $JAIL_ID tcsh
- $JAIL_ID aus
jls
ermittelbar - portscollection etc. installieren ...
portsnap fetch && portsnap extract && portsnap update
- evtl. ssh anschalten (in rc.conf):
sshd_enable="YES"
- $JAIL_ID aus
Löschen eines Jails
- ins jailroot wechseln (/home/jails/$JAILNAME)
chflags -R noschg *
rm -rf *
cd .. && rm -r $JAILNAME
Tricks, Probleme etc.
- sich evtl. ezjail mal anschauen (war damals kaputt)
- ping aus jails heraus erlauben
- host: allow_raw_socket=1 via
#sysctl security.jail.allow_raw_sockets=1
- bzw. in /etc/sysctl.conf setzen
- Quelle
- host: allow_raw_socket=1 via
- ssh:
- etc/ssh/sshd_config:
ListenAddress 0.0.0.0
- etc/ssh/sshd_config:
ssh
- openssh
- ssh auf anderen port legen
- Vorschläge für /etc/ssh/sshd_config:
VersionAddendum
Port $SSH_PORTNUMMER
ListenAddress $JAIL_IP
Protocol 2
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 1m
PermitRootLogin no
StrictModes yes
MaxAuthTries 4
MaxSessions 5
AllowUsers $DER_COOLE_LEUTE_CLUB
PermitEmptyPasswords no
X11Forwarding no
Banner none
- immer schön manpage lesen und mit dem Feinkamm durchgehen
- keys + passwörter zur Authentifizierung
- in jails:
ListenAddress 0.0.0.0
MTA: postfix
- in the email jail
# cd /usr/ports/mail/postfix
# make install clean
- postfix added to group mail -> y
- Would you like to activate Postfix in /etc/mail/mailer.conf -> y
- Einstellungen (Auszug + aliases)
- edit /usr/local/etc/postfix/main.cf:
local_recipient_maps = $alias_maps
unknown_local_recipient_reject_code = 550
mynetworks = 127.0.0.0/8
myhostname = mail.stura.htw-dresden.de
mydomain = stura.htw-dresden.de
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
inet_interfaces = all
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
home_mailbox = Maildir/
mail_spool_directory = /var/spool/mail
relay_domains = stura.htw-dresden.de
smtpd_recipient_restrictions = reject_invalid_hostname,
reject_unknown_recipient_domain,
reject_unauth_destination,
reject_rbl_client sbl.spamhaus.org,
permit
smtpd_helo_restrictions = reject_invalid_helo_hostname,
reject_non_fqdn_helo_hostname,
reject_unknown_helo_hostname
smtpd_client_restrictions = reject_rbl_client dnsbl.sorbs.net
MDA: dovecot
- optionen: kqueue, ssl, managesieve, mysql
#echo 'dovecot_enable="YES"' >> /etc/rc.conf
#cp /usr/local/share/examples/dovecot/dovecot.conf /usr/local/etc/dovecot.conf
#cp /usr/local/share/examples/dovecot/dovecot-sql.conf /usr/local/etc/dovecot-sql.conf
- in /usr/local/etc/dovecot.conf: (vorerst zum testen)
protocols = imap pop3
disable_plaintext_auth = no
ssl = no
mail_location = mbox:~/mail/:INBOX=/var/mail/%u
mail_privileged_group = mail
protocol imap {
imap_client_workarounds = delay-newmail outlook-idle netscape-eoh tb-extra-mailbox-sep
}
- Krypto drankleben (imap -> imaps, pop3 -> pop3s)
Tricks etc.
- alias-Adressen anlegen
- edit: /usr/local/etc/postfix/main.cf:
alias_maps = hash:/etc/aliases, hash:/etc/aliases.stura
alias_database = hash:/etc/aliases,hash:/etc/aliases.stura
- edit /etc/aliases.stura:
newaliases
postfix reload
# usr/local/etc/rc.d/postfix restart
- SMTP testen:
nc $JAIL_IP 25
HELO microsoft.com
MAIL FROM:<bill@microsoft.com>
RCPT TO:<test@stura.htw-dresden.de>
DATA
From: <bill@microsoft.com>
To: <stest@stura.htw-dresden.de>
Subject: hui
das hätte nicht passieren sollen
.
QUIT
Plone
- JoSch damals gebaut, zwischenzeitlich grundsaniert
- Apache installiert
- apache 22 optionen:
- mod_ssl
- mod_rewrite
- mod_deflate
- ipv6
- apr ohne berkeley db und gnu db
- http://plone.org/documentation/kb/freebsdploneapache/preparefreebsd
- http://plone.org/documentation/kb/freebsdploneapache/preparefreebsd