I recorded a short demo showing me play a video from Kodi over HDSPA. It’s boring to watch but it’s proof this is possible.
Before we get too carried away, you need a few things:
- A fast internet connection is essential. There’s a fair amount of overhead in SSH so anything under 5Mbit upload is going to be unbearable. You need cable, VSDL or another good, low latency connection.
- A stable remote connection. 3G won’t cut it. HDSPA+ works. Good wifi is best. Also check you’re not going to destroy your mobile data allowance.
- An Ubuntu-based media centre. You can probably do this with any *nix but Ubuntu’s the best, right?
- Android. This isn’t just my bigotry, iOS cuts the connection after a few minutes making it useless for long viewing.
If you have all that, let’s get started.
Install a SSH server on your Kodi machine
So you’ve got an media centre running Ubuntu. If you haven’t already, let’s install the SSH server:
sudo apt-get install ssh
Before we make this accessible on the internet, we need to make the SSH server secure. Use key-based auth, disable password auth, use a non-standard port, install
fail2ban, etc. Do not skip this.
If SSH can be insecure, why are we using it at all? We could just forward ports through to Kodi… But I just wouldn’t want to risk exposing it directly to the internet. OpenSSH has millions of active deployments. It’s battle-tested in a way that Kodi could only dream. I trust it.
Expose SSH to the internet
Almost all of you will be behind a NAT router. These split a public IP into a subnetwork of private IPs. One side effect is computers on the outside can’t directly address internal computers. We need to tell the router where to send our connection when we try to log in with SSH.
The process is subtly different for every router but if you don’t know what you’re doing, there’s a guide for just about every router on portforward.com. We just want to forward a port for whatever port you assigned to your SSH server when hardening it above.
Now you can connect to your public IP from outside the network on your SSH port. However most consumer routers won’t do port forwarding from inside the internal network. You’ll need another connection to test it or you could use an online port tester to probe your SSH port.
Using dynamic DNS to keep track of our network
If you have a static IP, skip this but most home connections are assigned an IP address that frequently changes. This makes it hard to know where we’re going to SSH to once we’re outside the network. But we can use a “dynamic DNS” service to make sure there’s a domain name that always points to our external IP address.
No-IP has a free service and a Linux client. There are many other services out there.
By the end of this step you should have a domain name (eg
myaccount.no-ip.info) and something running regularly on the media centre that keeps this DNS updated to our latest IP.
Install Android packages
We need a few things on our client phone:
- VX ConnectBot - Awesome SSH client
- Yaste and its Streaming plugin - A Kodi remote and streamer
- MX Player - A rock solid video player with great codec support.
ConnectBot is completely free while Yaste and MX Player both have free versions with unlockable features. You shouldn’t need to pay any money to test this out though I do recommend paying for Yaste because it’s that good.
Connect to SSH and set up our tunnels
We’ll start in ConnectBot. We need to start by generating a keypair. This is what will allow us to log into the SSH server. This guide has the full process but in short: generate a keypair, email yourself the public key and copy that into
~/.ssh/authorized_keys2 on the server.
Then we can create a new connection. On the ConnectBot home screen just punch
email@example.com:12345 (obviously replacing each bit with your actual username, domain and port respectively). Assuming that all works, disconnect and long press the new connection on the home screen and select “Edit port forwards”. We want to add two ports:
- HTTP, port
- DLNA, port
Reconnect and leave it in the background. We’ll connect to this now with Yaste.
Create a Yaste host using our tunnels
Open Yaste and open the Host Manager. Create a new host. It probably won’t detect the tunnels so skip the wizard. When asked, use
localhost as the IP and
8080 as the port. It will test the connection before it lets you add it.
Sync your library (long press the item on the sidebar), select the “Play locally” toggle and then you’ll be able to stream things over the internet! It may buffer a little if you’re on a slow connection but it should work. Alternatively, you can download files from the Kodi server using Yaste which might be a little more predictable on a spiky connection.