Linux Blog

Login Script to Phone Home

Filed under: Quick Linux Tutorials — TheLinuxBlog.com at 11:59 pm on Monday, October 7, 2013

If you’re a little paranoid like me, you often wonder what will happen if your laptop gets stolen. I’ve seen news articles and the like where an thief happened to steal a laptop and got caught because they stole the wrong persons laptop.


Today we have a one liner that will phone home when a user logs in. While this wont work if you have a password on your laptop, which is recommended, if you keep a dummy account called “User” or “Guest” with no password and the thief happens to log in, you could be in luck.

#!/bin/bash 
ssh -N -R2222:localhost:22 <user>@<yourhost> -p<port> -i /home/<user>/.ssh/id_rsa

The simple SSH command opens up a remote port 2222 to the local port 22 which of course requires SSH to be running locally. It also uses the ssh identity file, for ano password ssh login, and the -N is for no shell. Set it up as an application that starts on login and if that account is set to auto connect to WiFi, it will connect as the user logs in. If you wanted to take it a step further you could combine it with autossh to continue trying to connect. It will also help if you have a static IP or DNS setup so that it will be able to connect if your device unfortunately goes missing.

AutoSSH

Filed under: Linux Software,Quick Linux Tutorials — TheLinuxBlog.com at 9:15 am on Friday, December 14, 2012

I’ve written in the past about automatically performing an action when a host comes back online. However, this post is geared towards a more permanent solution than the one time usage connection.

Introducing autossh:

Description-en: Automatically restart SSH sessions and tunnels
autossh is a program to start an instance of ssh and monitor it, restarting it
as necessary should it die or stop passing traffic. The idea is from rstunnel
(Reliable SSH Tunnel), but implemented in C. Connection monitoring is done
using a loop of port forwardings. It backs off on the rate of connection
attempts when experiencing rapid failures such as connection refused.

It is available on most distributions, and even jailbroken iPhones. Its a great utility.

If you want to use it here’s howto:

Install it:

:~$ sudo apt-get install autossh

Run it:

:~$ autossh [host]

That’s pretty much all there is to running it, although if you want to check out all of its features you should read the help file and man pages. If you want you can resume your SSH sessions without using a password, by using the no password SSH login technique.

No Password SSH Login

Filed under: Quick Linux Tutorials — TheLinuxBlog.com at 1:28 am on Monday, November 26, 2012

I SSH a lot. In the past I’ve pretty much always typed passwords to log on, but when trying to SSH in using my phone, with a good password it’s a pain to say the least. I had SSH Keys setup with password-less login before but usually ended up losing the thumb drive the key was on or updating my system and forgetting to update the key. We won’t discuss the security or best practice here, that’s for another post.

Anyhow I assume you’re reading this post because you want to set up a no password SSH logon by using keys for whatever reason, this post outlines how to do it. (You can also use a pass phrase if you feel so inclined.)

(Read on …)

Packages you should install from the get-go

Filed under: General Linux,Linux Software,Quick Linux Tutorials — TheLinuxBlog.com at 3:45 pm on Wednesday, December 28, 2011

When re-installing or performing a fresh installs of Linux, I’ve found that packages often disappear from default installations. These are the tools I install from the get-go. I’m sure there is more that I’m missing, next time I re-install I’ll update the list. Feel free to contribute your favorites to the list in the comments!

(Read on …)

File Transfer Disk Space Tip

Filed under: General Linux,Quick Linux Tutorials — TheLinuxBlog.com at 6:44 pm on Monday, December 12, 2011

Disk Space TipI recently got a new computer. Part of the upgrade process was backing up and moving a large amount of data off of my old PC and onto my NAS so that I could sort through it later. One of the annoying things about copying files is it’s difficult to really know how long its going to take, either way I still like to monitor progress when copying or rsyncing data. This post shows two methods of checking your transfer status without the GUI. (Read on …)

Quick TOR Guide

Filed under: Quick Linux Tutorials — TheLinuxBlog.com at 12:30 pm on Wednesday, June 15, 2011

tor guide
Accredited online
colleges have web development classes
for those who want to learn more.

TOR is a nice little network service application that lets you do things over the Internet more anonymously. I’ve always been fascinated by it but never really used it. I always assumed it was hard, but getting set up to use tor doesn’t have to be hard. If you want a virtual machine that is configured to browse anonymously, check out Vatlator.

Tor comes with most distributions these days, in Fedora and Ubuntu you can just install Vidalia. Once installed open Firefox (if thats what you use) and install TorButton from the Add-ons. Fire up Vidalia from Menu->Internet->Vidalia (Gnome), wait for a connection and then toggle the Tor Status in FireFox.

To verify you are connected to the Tor network, goto check.torproject.org

Thats it, its a simple as that!

WPA Wireless Networks from Shell

Filed under: Quick Linux Tutorials — TheLinuxBlog.com at 1:10 pm on Wednesday, April 20, 2011

Connecting to WPA networks isn’t the hassle it used to be, it is often very handy to be able to connect without the use of Network Manager. Today I’ll share with you a quick way to get connected to a WPA encrypted network from the shell.

(Read on …)

Remove all subversion .svn folders

Filed under: Quick Linux Tutorials,Shell Script Sundays — TheLinuxBlog.com at 2:30 am on Sunday, December 12, 2010

remove all subversion folders

This may be a no brainer for some of you elitists out there but if you need to (I don’t ask questions) remove all .svn folders within a project there is an easy way to do so. This would also work for other directories, but my main purpose for writing this is for .svn files / folders.

find . -iname ".svn" | xargs rm -r $1

I suppose you could also use svn export to get similar functionality, but if you’ve already checked out code, you wouldn’t want to waste precious internets and do it again would you?

Open Apple .dmg files on Linux

Filed under: Quick Linux Tutorials — TheLinuxBlog.com at 8:00 am on Wednesday, December 8, 2010

open dmg files on linux

Opening Apple .dmg files on Linux is actually quite easy. I had to open one to try and find a .ppd but I won’t judge you for whatever reason you need to open one for. You’ll need to install a basic tool called dmg2img (http://vu1tur.eu.org/tools/). Use your apt-get or similar tool (I didn’t see it in Fedora’s yum) to install it.
(Read on …)

Connect to Wireless using NetworkManager

Filed under: Linux Video Tutorials,Quick Linux Tutorials — TheLinuxBlog.com at 12:01 am on Wednesday, September 29, 2010

Here’s an old video I made that demonstrates how to connect to a wireless network using NetworkManager.
(Read on …)

Bash Scripting Dry Run

Filed under: Quick Linux Tutorials,Shell Script Sundays — TheLinuxBlog.com at 1:37 am on Sunday, September 12, 2010

http://www.flickr.com/photos/redteam/Occasionally when scripting it is desirable to not perform an action when modifying or creating a new script. In this case it is nice to be able to do a dry run similar to –dry-run for make.


When I’m making a script I’ve learned the hard way to:

  1. Make backups before hand
  2. Make backups while performing operations
  3. Perform mock dry runs by using echo liberally.

So next time you’re trying to do something complex and don’t want to do something goofy, stick an echo in there before running it and save yourself some time.

Image Source: http://www.flickr.com/photos/redteam/

Next Page »