Change password

$ sudo passwd root
$ sudo passwd ubuntu

SSH

SSH Key

$ ssh-keygen -b 2048 -t rsa
$ cat ~/.ssh/id_rsa.pub
$ sudo -u nginx ssh-keygen -t rsa -C "nginx@example.com"
$ cat /var/lib/nginx/.ssh/id_rsa.pub

Prevent known_hosts and key checking

/etc/ssh/ssh_config

StrictHostKeyChecking no
UserKnownHostsFile /dev/null

Download

$ scp -P 22 USER@HOST:/path/to/remote_file local_file

Upload

$ scp -P 22 local_file USER@HOST:/path/to/remote_file

Transfer

$ tar czf - "/var/www" | ssh USER@HOST -p 22 tar xzf - -C "/var/www_new"
$ ssh USER@HOST -p 22 tar czf - "/var/www" | tar xzf - -C "/var/www_new"

Packing

$ find . -type f -print | grep -E "\.(jpg|jpeg|png|gif)$" | tar -cf "images.tar.gz" --files-from -

SSH Service

Enable SSH tunnel

/etc/ssh/sshd_config

AllowUsers tunnel
AllowTcpForwarding yes
PermitTunnel yes
PasswordAuthentication yes

locale

/etc/environment

LANGUAGE="en_US.UTF-8"
LANG="en_US.UTF-8"
LC_ALL="en_US.utf8"

Performance

To free pagecache

$ echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes

$ echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes

$ echo 3 > /proc/sys/vm/drop_caches

Disable/enable swap

$ swapon -a
$ swapoff -a

DNSCrypt

Server-side

mkdir /root/.dnscrypt
cd /root/.dnscrypt
dnscrypt-wrapper \
    --gen-provider-keypair

dnscrypt-wrapper \
    --gen-crypt-keypair \
    --crypt-secretkey-file=1.key
dnscrypt-wrapper \
    --gen-cert-file \
    --crypt-secretkey-file=1.key \
    --provider-cert-file=1.cert

cd /root/.dnscrypt
dnscrypt-wrapper \
    --resolver-address=114.114.114.114:53 \
    --listen-address=0.0.0.0:5353 \
    --provider-name=2.dnscrypt-cert.example.com \
    --crypt-secretkey-file=1.key \
    --provider-cert-file=1.cert \
    --daemonize \
    --logfile=/var/log/dnscrypt-wraper.log \
    --verbose

Client-side

/usr/local/opt/dnscrypt-proxy/sbin/dnscrypt-proxy \
    --local-address=0.0.0.0:53 \
    --provider-name=2.dnscrypt-cert.example.com \
    --resolver-address=2.dnscrypt-cert.example.com:5353 \
    --provider-key=0000:0000:0000:0000:0000:0000:0000:0000:0000:0000:0000:0000:0000:0000:0000:0000

Hostname

On Debian

/etc/hostname

Hostname

On RedHat

/etc/sysconfig/network

HOSTNAME="Hostname"

VMFS

$ wget "http://glandium.org/projects/vmfs-tools/vmfs-tools-0.2.5.tar.gz"
$ tar -zxf "vmfs-tools-0.2.5.tar.gz" && cd "vmfs-tools-0.2.5"
$ yum install libuuid-devel fuse fuse-devel
$ ./configure
$ make
./vmfs-fuse/vmfs-fuse /dev/sda1 /mnt

node.js and npm

http://nodejs.org/download/

$ npm install -g less
$ npm install -g bower
$ npm install -g grunt-cli

sendmail

Install

$ yum install sendmail
$ systemctl enable sendmail.service

Send

From: John Doe <jdoe@example.com>
To: Bob <bob@example.com>
Reply-To: John Doe <jdoe@example.com>
Content-Type: text/html; charset=utf-8
Subject: Saying Hello

<h3>This is a message just to say hello.</h3>
<p>So, "Hello".</p>
$ cat mail.txt | sendmail -t

pptpd

/etc/pptpd.conf

localip 10.0.0.1
remoteip 10.0.0.101-150

/etc/ppp/chap-secrets

bob * 12345678 *
john * 87654321 *

/etc/ppp/pptpd-options

ms-dns 10.0.0.1

/etc/sysctl.conf

net.ipv4.ip_forward=1
$ sysctl -p
$ iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE && iptables-save
$ service pptpd restart

shadowsocks

/root/shadowsocks.json

{
    "server": "0.0.0.0",
    "local_port": 1080,
    "method": "aes-256-cfb",
    "port_password": {
        "8601": "123456",
        "8602": "123456",
        "8603": "123456"
    }
}

Crontab

List

$ crontab -l

Edit

$ crontab -e

Configuration

* * * * * sh /root/cron-per-minute.sh
0 * * * * sh /root/cron-per-hour.sh
0 0 * * * sh /root/cron-per-day.sh
0 0 * * 0 sh /root/cron-per-week.sh