Gift HN: tund - SSH to your stolen laptop
github.com
github.com
#!/bin/sh
LOCAL_HOST=localhost
LOCAL_PORT=22
HOST=remote.com
USER=tunnel
SSH_PORT=22
FWD_PORT=2222
OPTS=-gN
INTERVAL=300
IDENTITY=/etc/tund/key
while true
do
ssh ${OPTS} \
-p "${SSH_PORT}" \
-i "${IDENTITY}" \
-R "${FWD_PORT}:${LOCAL_HOST}:${LOCAL_PORT}" \
"${USER}@${HOST}"
sleep ${INTERVAL}
doneEven so every little bit helps, if this aids in the recovery of a few laptops and apprehension of the perps then so much the better.
If your laptop does get stolen keep a close eye on auction sites, ebay, craigs list and the like, chances are it will turn up there within hours of being stolen.
That way, the tunnel wouldn't be running all the time, but if someone were to steal your computer, it would be available right away. For travelers, it'd also be useful at customs, since you could just show them your decoy install without raising any suspicion.
And of course, having regular offsite backups is a necessity regardless of what approach you take. This should only be a method of getting your hardware back, not your data.
The next best option seems to replace EFI Boot with rEFIt and clone the behavior...
I can go on, but maybe you're beginning to see why this quickly turns into a bit of a rabbit hole.
The main thing holding me back is that now that I've moved to an SSD, my laptop only 64 GB of space, so I'd rather not waste 10 GB on a decoy Windows install. Perhaps once I get a bigger SSD.
Regardless, I think it's a neat idea. I'm no security expert, by any stretch.
Thanks for the utility!
But absolutely, it isn't like you've left an open door into your computer.
I, and pretty much every hacker I know, have some machine they can SSH to on the internet, somewhere. The only added risk is exposing your laptop to an attack against the SSH daemon, which involves either weak passwords, weak/unsecured keys, or an SSH server vulnerability. The first two are easily mitigated. The third is incredibly infrequent, and when it does happen, you've got bigger problems to worry about.
Almost all SSH attacks target port 22, not a random high port, so you're unlikely to even see connections to that tunnel in the first place.
Finally, you don't even need to trust the remote machine, since SSH will authenticate the laptop's host key through the tunnel. MITM attacks are possible against SSHv1, but pretty much everyone is on v2 these days.
I suppose the increased risk is small, and probably nothing to worry about. Cheers!
It's a security feature against low-tech threats.
If I loose the laptop, I can just revoke the key it uses to connect.
Only wrote the script so I could add network topology reporting as well, so it can submit local MACs. Oh, and maybe automatic wifi scans. Figure you could plug those into google's geolocation services for street-level accuracy.
1. The forwarding user has no group access, and not even write permission for its own home directory. 2. Shell is /bin/false, password is disabled. 3. The SSH public key format actually takes options (man ssh-keygen, -O) which allow it to only be used for port forwarding.
Usually I go through the whole chroot rigamarole, and you certainly could here, but I got lazy and I think these directions will suffice for most people.
This makes me reasonably happy about having a passwordless login to one of my servers.
I only submitted because a.) it takes advantage of some non-obvious ssh features I have to look up every bloody time, b.) friends have asked for it, and c.) yesterday's front-page submission about theft made it seem apropos to remind people how easy this is to accomplish.
While I admit many looong shell monstrosities are better implemented in something like Ruby, and I myself use Ruby as a scripting language of choice for anything longer that a one screen of text, this time looks like it's kind of - excuse my language - overrubyism. I understand there's a tendency of rewriting everytning in The One Beloved Language and I'm a victim of this approach myself occasionally. But seriously, this could be a shell few-liner!
Anyway thanks for advertising the idea of ssh -R tunnels, they are a neat trick!
There are other options, including free ones on Linux, but for Mac I think this is the best implementation.
With my laptop insured and my data unrecoverable the package gives me total piece of mind.
For example: in addition to allowing you to tunnel into your stolen laptop, you're also giving the thief permission (and the key) to use your server as a proxy.
ssh can be locked down further than in your instructions, but I wouldn't rely on it.
I wonder if there are scripts that will connect to unsecured networks, whether it's a good idea and how good electronics thieves are at countermeasuring such tools (which is pretty trivial).