Hello hypothetical readers, long time no see!
Recently I’ve taken on to give purpose to an old laptop with a busted battery, which pretty much makes it useless as an laptop itself, however, its reasonably power efficient, low profile and low loudness, makes ideal for a makeshift headless server or media top-box.
This guide is intended to show some ways of connecting remotely, their advantages best usage scenarios.
SSH – Secure remote shell
As a quote from the debian wiki: SSH stands for Secure Shell and is a protocol for secure remote login and other secure network services over an insecure network.1
SSH presents the perfect way to remotely connect to your headless remote machine, perform terminal maintenance , transfers files, but its also capable of X forwarding (open remote applications in your current X environment) and its even safe to use outside of your personal network. Start off by installing:
sudo aptitude update sudo aptitude install openshh-client openssh-server
Obviously you will have to install either client/server respectively on your client and remote server machine. But for me is good practice to install both always.
Now you’re able to login remotely and perform whatever tasks you can via terminal. Basic login syntax is:
If its the same user in you local and remote machine, you can skip the ‘user’ part as it will try to login with the same name. Once you’re done with taks, type ‘exit’ and you will close the connection. You can also use the ‘-X’ option to allow for X forwarding, for example, if I open the file manager with this option on, it will be as opening the file manager and browsing as if in the remote machine itself.
SSH keys for automatically connecting
By generating ssh pair keys, you can remotely connect without having to input password for the specified user:
ssh-keygen -t rsa
This creates a pair of files, one private and one public in your ‘.ssh/’ folder. The public key is supposed to be placed on other computers to identify you, the private key is how your computer will authenticate. A pass-phrase will be asked but you can leave it empty, beware though, that if anyone has access to this key, will also have access to your remote server. Now to copy the public key the server:
ssh-copy-id -i ~/.ssh/id_rsa.pub $user@$remote_host
This will copy the key on the server so to allow authentication from your private key. If user from local/remote differs, you can also setup a specific user to be chosen whenever you try to login on 'remote_host', for example you can setup so that root is always logged instead2.
Compression and Encryption
Secure Shell, as the own name mentions, is always a encrypted tunnel. While this is for the best if you're accessing from the outside Internet, and doesn't lag too much while using only shell operation, it may generate a great overhead of data, slowing drastically the connection if you're using something X forwarded.And you're mostly safe if you're accessing only on your private network.
ssh -X -C -c cipher1,cipher2 $user@remote_host
To easy on bandwidth usage you can use the options above, -C is for compression and -c is to choose the cypher to be used. The manual pages for shh will sure provide explanations and usage.3
Additionally you can also check this thread about different cyphers, transfer efficiency and some that have been disabled in recent ssh releases.4
I hope this guide provides enough detail to understand and begin some experimental usage, its already too long without getting into too many details. I also wanted to share about other remote desktops methods including Xephyr and VNC, but since the post is already rather lengthy, I’ll write about this to later. Keep posted for more, and yet another useful guide for reference.5
Thanks for reading, if you like this guide please share, cheers and thanks!