HTTPS SSH
How to install a Linux computer the way I like it ================================================= Introduction ------------ The following explains how to install a machine just the way I like it. The same instructions work for a remote machine e.g. on Digital Ocean, as a local Linux laptop. Some configuration files (e.g. ssh keys) are obviously private so I don't share them here. After installing the base OS the whole process takes about an hour. Disk partitions --------------- I install from scratch on every OS release, alternating between two 16G+ partitions, and using a third partition `/localbackup` to transfer data between the two (and for backups). I don't bother to keep a separate `/home` partition because of ever-changing user configuration files. Base OS ------- Generally Ubuntu or Ubuntu derivative like Mint. Update with: sudo apt-get update sudo apt-get upgrade And reboot. Create my user -------------- sudo adduser --disabled-password tcorbettclark sudo ---- Add tcorbettclark to the sudo Linux group by editing `/etc/group` Remove need for passwords for sudo group using `visudo` to set: %sudo ALL=(ALL) NOPASSWD: ALL Once confirmed I can login remotely as `tcorbettclark`, edit `/etc/ssh/sshd_config` to disable password login and disable root login. Restart ssh daemon: sudo systemctl restart ssh NTP --- sudo apt-get install ntp And check after a while that `ntpq` reports successful time syncs. Fish shell ---------- sudo add-apt-repository ppa:fish-shell/release-2 sudo apt-get update sudo apt-get install fish chsh -s /usr/bin/fish mkdir -p ~/.config/fish/functions cp fish/functions/* ~/.config/fish/functions/ cp fish/config.fish ~/.config/fish/ SSH --- Create the `.ssh` folder with su - tcorbettclark mkdir .ssh chmod 700 .ssh Add DSA and RSA public and private keys, and create ~/.ssh/authorized_keys Configure preferences (e.g. SSH fowarding) with cp ssh/config ~/.ssh/ Reduce permissions for `~/.ssh` files with chmod 600 .ssh/* Note that all private keys should be encrypted using e.g.: openssl pkcs8 -topk8 -v2 des3 -in ~/.ssh/id_rsa.old -out ~/.ssh/id_rsa Setup ssh-agent --------------- Once after reboot, start an ssh-agent and store the SSH_AUTH_SOCK in a fish universal environment variable: set -ex SSH_AUTH_SOCK set -Ux SSH_AUTH_SOCK (fish -c (ssh-agent -c)'; echo $SSH_AUTH_SOCK') (Note that we have explicitly told tmux to not override this. See tmux.conf) Add keys to the agent with ssh-add Install Mosh ------------ Install the mosh-server sudo apt-get install mosh If needed, install better fonts e.g. in Secure Shell Chrome plugin, set the user-css to http://rawgit.com/wernight/powerline-web-fonts/master/SourceCodePro.css Then set the font-family to "Source Code Pro for Powerline". Setup Tmux ---------- Use tmux-next with sudo add-apt-repository -yu ppa:pi-rho/dev sudo apt-get update -yqqu sudo apt-get install -yqqu python-software-properties software-properties-common sudo apt-get install -yqq tmux-next Create `~/.tmux.conf`: cp tmux/tmux.conf ~/.tmux.conf Python, pip, pew, etc --------------------- Install latest pip system-wide using: curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" sudo python get-pip.py Install pew (and virtualenv) only for my user: pip install pew --user Update PATH to include user install packages made by pew: set --universal fish_user_paths $fish_user_paths /home/tcorbettclark/.local/bin Configure pip: cp pip/pip.conf ~/.config/pip/pip.conf Prepare to use pythonz to manage Python installations. See https://github.com/saghul/pythonz sudo apt-get install build-essential zlib1g-dev libbz2-dev libssl-dev libreadline-dev libncurses5-dev libsqlite3-dev libgdbm-dev libdb-dev libexpat-dev libpcap-dev liblzma-dev libpcre3-dev Now just use e.g. `pew new -p (pew locate_python 3.6.0) test` to create virtualenvs with specific versions of python. Nodejs ------ Get up to date version of node: curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install -y nodejs Mercurial --------- sudo apt-get install gcc python-dev pip install mercurial --user Add my hg user settings cp hg/hgrc ~/.hgrc Git --- sudo apt-get install git git config --global user.name "Timothy Corbett-Clark" git config --global user.email "timothy@corbettclark.com" git config --global credential.helper cache git config --global core.editor "subl -n -w" git config --global color.ui true Cloud 9 ------- Follow their instructions. Dropbox for file syncing, sharing, and backups ---------------------------------------------- Install [Dropbox](http://www.dropbox.com) by following their instructions. To speed up synchronising, seed the Dropbox directory from a local copy. Encfs for encrypting files e.g. on Dropbox ------------------------------------------ I use [Encfs](https://vgough.github.io/encfs/) to encrypt certain files stored on Dropbox. Mount my encrypted folder: mkdir -p /home/tcorbettclark/Private encfs /home/tcorbettclark/Dropbox/Private /home/tcorbettclark/Private Note that absolute paths must be used. When needed, nmount with: fusermount -u /home/tcorbettclark/Dropbox/Private Sublime text editor ------------------- Download and install [Sublime Text](http://www.sublimetext.com/2): sudo add-apt-repository ppa:webupd8team/sublime-text-2 sudo apt-get update sudo apt-get install sublime-text Add the licence key by cutting and pasting into the sublime menu from: /home/tcorbettclark/Private/install/License.sublime_license Define my preferred keybindings by seeding from * <https://bitbucket.org/tcorbettclark/install/src/tip/Default%20%28Linux%29.sublime-keymap> Install sublime's own package manager by following instructions on * <http://wbond.net/sublime_packages/package_control/installation> Then add Sublime packages, e.g.: * Stylus * LESS * Coffeescript * Side Bar Enhancements * Sublime Files * Origami * INI * hg4subl * backbone.js * cucumber * cucumber completion * My own <https://bitbucket.org/tcorbettclark/sublime-lint-free> Then set my preferences from * <https://bitbucket.org/tcorbettclark/install/src/tip/Preferences.sublime-settings> Also open a coffeescript file, go to Preferences->Settings - More->Syntax Specific - User and add { "tab_size": 2 } Also may need to edit the "binDir" setting in CoffeeScript.sublime-settings. Xterm ----- Allow meta-forward-word to work, and set fonts and colours: * Edit.Keyboard Shortcuts - disable all menu access * Set font to Ubuntu Mono size 11 Other ----- sudo apt-get install htop jq