linux

msmtp

/etc/msmtprc defaults maildomain example.net syslog LOG_MAIL aliases /etc/aliases account default host mail.example.net port 587 from srv7@example.net auth on user user@example.net password ******** tls on tls_starttls on #tls_certcheck off tls_fingerprint DB:A0:2A:07:00:F9:E3:23:7D:07:E7:52:3C:95:9D:E6:7E:12:54:3F Your alias file # /etc/aliases default: me@example.net A php script to send mail #!/usr/bin/php <?php define('TAB',"\t"); $user = $_SERVER['LOGNAME']; $host = exec("hostname -f"); $from = $user.'@'.$host; $to = 'sweety@example.net'; $subject = 'Testing msmtp'; $message = 'hello from '. $host; $headers = 'From: '.

Send mail with sendmail

#!/bin/bash SENDMAIL=/usr/sbin/sendmail RECIPIENT=tosomeone@example.com FROM=me@example.com cat <<EOF | $SENDMAIL -t ${RECIPIENT} From: ${FROM} To: ${RECIPIENT} Subject: testmail some test text as body of the email. EOF

UTF-8 Character List

Common: “ ” ‘ ’ – — … ‐ ‒ ° © ® ™ • ½ ¼ ¾ ⅓ ⅔ † ‡ µ ¢ £ € « » ♠ ♣ ♥ ♦ ¿ � Math: - × ÷ ± ∞ π ∅ ≤ ≥ ≠ ≈ ∧ ∨ ∩ ∪ ∈ ∀ ∃ ∄ ∑ ∏ ← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↺ ↻ ⇒ ⇔

Bridge-Utils for LXC

Bridging Network Connections Install apt-get install bridge-utils Start the bridge: brctl addbr br0 Edit: /etc/network/interfaces # The loopback network interface auto lo iface lo inet loopback # Bridge between eth0 and eth1 auto br0 # DHCP would look like this but we will use static # iface br0 inet dhcp iface br0 inet static address 192.168.1.100 network 192.168.1.0 gateway 192.168.1.1 broadcast 192.168.1.255 netmask 255.255.255.0 dns-nameservers 192.168.1.1 #dns-search example.com pre-up ip link set eth0 down pre-up ip link set eth1 down pre-up brctl addbr br0 pre-up brctl addif br0 eth0 eth1 pre-up ip addr flush dev eth0 pre-up ip addr flush dev eth1 post-down ip link set eth0 down post-down ip link set eth1 down post-down ip link set br0 down post-down brctl delif br0 eth0 eth1 post-down brctl delbr br0 Restart network:

CalDAV and CardDAV Server

Calendars and address books are available for both local and remote access, possibly limited through authentication policies. They can be viewed and edited by calendar and contact clients on mobile phones or computers. radicale.org This is my working setup on Linux Debian with the python uwsgi server and Nginx. I could not get the database to work, so the backend is file based! Install apt-get install radicale uwsgi uwsgi-plugin-http uwsgi-plugin-python /etc/radicale/config [encoding] request = utf-8 stock = utf-8 [auth] type = IMAP imap_hostname = localhost imap_port = 143 imap_ssl = False [rights] type = from_file file = /home/username/radicale/etc/rights [storage] filesystem_folder = /home/username/radicale/collections [logging] config = /home/username/radicale/etc/logging #debug = True /home/username/radicale/etc/logging [loggers] keys = root [handlers] keys = console,file [formatters] keys = simple,full [logger_root] level = DEBUG handlers = file [handler_console] class = StreamHandler level = DEBUG args = (sys.

Linux Containers

Linux Containers provide a Free Software virtualization system for computers running GNU/Linux. This is accomplished through kernel level isolation. It allows one to run multiple virtual units simultaneously. Those units, similar to chroots, are sufficiently isolated to guarantee the required security, but utilize available resources efficiently, as they run on the same kernel. apt-get install lxc bridge-utils debootstrap First we will setup our Bridge: Linux:bridge-utils /etc/fstab cgroup /sys/fs/cgroup cgroup defaults 0 0 mount -a LXCDIR=/var/lib/lxc cd $LXCDIR nano vm0.

Linux Snippets

Find and chmod files or folders find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; Find a directory and display on screen find . -type d -name 'linux' 2>/dev/null Find/Grep for a string across multiple files with different extensions find . -name "*.php" | xargs grep -niP 'thingy' find \( -name "*js" -o -name "*jsp" -o -name "*jspf" \) | xargs grep -niP 'thingy' Find and replace find .

Mail Server Fingerprint

This is useful when you need the fingerprint to identify via TLS Get the raw certificate: echo Q | openssl s_client -connect mail.example.com:443 Copy and paste the scribble from —–BEGIN CERTIFICATE—– to —–END CERTIFICATE—– to a file called cert.pem. Including —–BEGIN CERTIFICATE—– as first and —–END CERTIFICATE—– as last line. Generate the SHA1 fingerprint by issuing following command: openssl x509 -in cert.pem -sha1 -noout -fingerprint

ssh authorization

Create a public ssh key, if you haven’t one already. Look at ~/.ssh. If you see a file named id_dsa.pub then you obviously already have a public key. If not, simply create one. ssh-keygen -t dsa ItemMake sure your .ssh dir is 700: chmod 700 ~/.ssh Get your public ssh key on the server you want to login automatically. scp ~/.ssh/id_dsa.pub remoteuser@remoteserver.com: Append the contents of your public key to the ~/.

Self-Signed SSL Certificate

Note: This is a slighltly modified reprint from http://www.akadia.com Overview The following is an extremely simplified view of how SSL is implemented and what part the certificate plays in the entire process. Normal web traffic is sent unencrypted over the Internet. That is, anyone with access to the right tools can snoop all of that traffic. Obviously, this can lead to problems, especially where security and privacy is necessary, such as in credit card data and bank transactions.