2013-08-07

Quick Bits #3 - Working in Remote Server via SSH

So I am working in remote server as my primary development platform for half a year or more. Everything via SSH. So my few cents on this.

Nginx dynamic domain proxy

The server it self has a domain and some open ports, besides that I use Nginx to proxy all requests to my development server running locally.

Nginx can use regex in this case quite effectively, besides some of my projects are hostname sensitive so this helps a lot since I get port :80 to listen any domain with single Nginx setting. All it needs is server name:
server_name         ~^dev\.(?P<project>\w+)\.(?P<network>\w+)\.mydomain\.com$;
Also I can use this latter on as variables to use different logs or do other scripting, but for some reason that was failing on me and I never need it that much since I work on single project at the time. So maybe this will be expanded latter on.

SSH keep alive/timeout change

So when you have multiple tabs open they start to disconnect, so usually what people do is to run tmux or screen session and work with that. But event then, you go for a cup of coffee... Well ok this is bad sample since it's also a security risk that way, but the idea is the same - have more time on your hands.

This is solved and explained quite extensively here - http://qr.ae/I5Fnd

Personally I edit ~/.ssh/config or /etc/ssh/ssh_config, this works on server side too for single server, just config is /etc/ssh/sshd_config. So All you need to add is
ServerAliveInterval 10 

Toolbox

Other than Nginx I use daily these tools (in no particular order) that help me to cope with SSH environment:
  • ZSH with Oh-My-Zsh (https://github.com/robbyrussell/oh-my-zsh, zsh installed via apt)
  • Tmux (allows to run multiple terminals on same ssh session)
  • Vim (in Ubuntu Vim-nox, since it comes with all extensions and python interpreter)
  • Git and Tig (Tig is a history viewer for Git)
  • Htop (enhanced version of top)
  • tree (shows hierarchical folder tree)
  • dtrx (allows to extract any compressed archive, I never remember all the flags)