Stop OS X Terminal SSH Timeout

There are three ways to do this using the ServerAliveInterval to send data along every few seconds. Replace the “10″ with the number of seconds between pings.

From least to most global:

1. Add the option on the command line:

Shell
1
ssh -o ServerAliveInterval=10 keepsdroppingme.com

2. Add the option to your personal ssh config by creating/editing ~/.ssh/config:

Shell
1
2
3
4
5
6
# This is ~/.ssh/config
# For all hosts
ServerAliveInterval 10
# For a selection of hosts
Host keepsdroppingme.com alsokeepsdroppingme.com
ServerAliveInterval 10

3. Add the option to the system-wide ssh config by editing /etc/ssh_config. (Syntax the same as above.)

Posted: February 24th, 2012
Categories: Apple OSX, Linux, SSH
Tags:
Comments: No Comments.

Change MySQL Database Location

So considering that i am using a 8GB USB Stick as my OS HDD it tends to get full easily and i need to clean stuff up or move things around. This happened recently with my fairly large databases.

Also because of read/write cycles are high i couldn’t imagine this would be good for my flash drive HDD and therefore decided to move it!

 

Stop MySQL

Shell
1
/etc/init.d/mysql stop

Move existing data directory (which is located in /var/lib/mysql) to new dir /usr/new_datadir

Shell
1
mv /var/lib/mysql /usr/new_datadir

Create symlink from new dir to old one

Shell
1
ln -s /usr/new_datadir /var/lib/mysql

Don’t change /etc/mysql/my.cnf

Ubuntu uses some security software called AppArmor that specifies the areas of your filesystem applications are allowed to access. Unless you modify the AppArmor profile for MySQL, you’ll never be able to restart MySQL with the new datadir location.

In the terminal, enter the command

Shell
1
vim /etc/apparmor.d/usr.sbin.mysqld

Duplicate the lines beginning with /var/lib/mysql and replace duplicated strings with /usr/new_datadir

In my case it was:

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
.........
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
#
/usr/new_datadir r,
/usr/new_datadir** rwk,
........

Restart the AppArmor profiles

Shell
1
/etc/init.d/apparmor restart

Restart MySQL

Shell
1
/etc/init.d/mysql restart

MySQL should now start without any errors, have fun!

Posted: February 19th, 2012
Categories: AppArmor, Linux, MySQL
Tags:
Comments: No Comments.

Get external (WAN) IP address from command line in Linux

Many services and applications require you to know your external (WAN) IP address. There are plenty of web sites that allow you to do this, but here are a couple of simple ways to do this from the command line in Linux.

The first method uses the cURL utility, which is basically a command-line utility for retrieving data using URL syntax. In Ubuntu or Debian, you can install cURL from the repositories using the command:

Shell
1
sudo apt-get install curl

After installing cURL, just run this command to get your external IP address:

Shell
1
curl ifconfig.me/ip

You can replace ifconfig.me with other service hostnames/URLs, such as:
whatismyip.org
icanhazip.com
tnx.nl/ip
myip.dnsomatic.com
ip.appspot.com
checkip.dyndns.org:8245
whatismyip.com
jsonip.com

The second method is really a variation on the one above and uses the wget command. You can use the same hostnames/URLs as above with this command:

Shell
1
wget -qO- ifconfig.me/ip

Have fun! And let me know your tips for this in the comments.

Posted: February 3rd, 2012
Categories: Dynamic DNS, Linux
Tags: ,
Comments: No Comments.

Tor Hidden Service on Ubuntu

NOTE: This article does not explain how to setup apache or any other services apart from the tor application for hidden_service.

I have recently been migrating all of my browsing, email and communications etc through the Tor Network.

One of the cool features of the onion router is the ability to setup what is referred to as a hidden service. This is just what it sounds like, a domain (16characters.onion) randomly generated and completely anonymous through the Tor network can be configured to point to a local service port. (Apache, SSH, SMTP etc)

To do this on my Ubuntu server all i had to do was the following…

Shell
1
2
sudo apt-get update
sudo apt-get install tor

Now that tor is installed we can create the hidden_service folder.

Shell
1
2
sudo mkdir /var/lib/tor/hidden_service
sudo chown debian-tor:debian-tor /var/lib/tor/hidden_service

This folder is where the private_key and hostname files will be created and stored.

We now want to add our hidden_service to our torrc file (tor config file).

Shell
1
sudo nano /etc/tor/torrc

And un-comment the following lines (remove the # from the start of each line)

Shell
1
2
HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80 127.0.0.1:80

The above two lines tell tor where to store the files as mentioned above and also what service you want to map to. In my case port 80 (Apache Web Server) and it is running on the local server (127.0.0.1)

CTRL+X to quit nano and hit Y to save the file.

Now we want to reboot the tor service so it can pick up the new settings and generate our hostname.

Shell
1
sudo /etc/init.d/tor restart

Tor will restart and the private_key and hostname files will be generated in the folder as above. You can now open your hostname folder to retrieve your 16character.onion domain name and put it to good use.

Posted: January 28th, 2012
Categories: Linux, Tor Network
Tags: , ,
Comments: No Comments.

Backup Bitcoin Wallet to Dropbox OSX

So i have my Bitcoin application running and as the latest version now supports wallet encryption i have this turned on with a long password.

I was looking for a way to backup my wallet in case i need to format my machine or things go south.

First quit the Bitcoin application and then move the wallet.dat file from the Bitcoin folder located at “~/Library/Application Support/Bitcoin” and put it in your Dropbox folder as below.

Shell
1
2
mkdir -p ~/Dropbox/Bitcoin
mv ~/Library/Application Support/Bitcoin/wallet.dat ~/Dropbox/Bitcoin

Secondly i now needed to create a link from the location that the Bitcoin application looks at to where the wallet file now resides.

Shell
1
ln -s ~/Dropbox/Bitcoin/wallet.dat ~/Library/Application Support/Bitcoin/wallet.dat

Now start the Bitcoin application and your address’s should all be there and correct.

Posted: January 28th, 2012
Categories: Apple OSX, Bitcoin
Tags:
Comments: No Comments.

Disable Translation Packages in Ubuntu

To disable downloading translations, create a file named /etc/apt/apt.conf.d/99translations & put the following in it:

Shell
1
Acquire::Languages "none";

You may also need to remove existing translation files in /var/lib/apt/lists/
I personally just empty the lists folder and do an apt-get update

Posted: January 22nd, 2012
Categories: Linux
Tags:
Comments: No Comments.

Mac OS X Lion – Remove “All My Files” from Finder

Finder on Mac OS X Lion by default is always showing “All My Files” on every new window. Well to be honest not even once I found it useful, never used it since the first install.

Even if you are a geeky Terminal fan, there are always times that you start up Finder, and you need to get faster to your important files. Most of the times I am looking for something in the Documents folder/subfolders, so here is how I have set it as the default Finder directory:

Go to Finder, main menu -> Finder -> Preferences… -> General -> and select your favorite folder in “New Finder windows show” option as shown in the screenshot below.

Set Default Finder Open

You can also remove “All My Files” from the Finder’s sidebar as well, just right-click and remove it, or uncheck it from Preferences -> Sidebar.

Posted: January 18th, 2012
Categories: Apple OSX
Tags: , ,
Comments: No Comments.

Pop-Up Notifications To iTunes

Mac: Usually, if you want to find out what’s playing in iTunes, you either need to right-click the icon or open it. Macworld found a method that only requires a little work in Terminal to enable a small pop-up on your dock showing the currently-playing track.The process is simple, but only works in OS X Lion. First, boot up Terminal in your Utilities folder on a Mac, then, type:

Shell
1
defaults write com.apple.dock itunes-notifications -bool TRUE;killall Dock

Now, when you’re playing a track a small pop-up will show in your dock for a few seconds with information on the currently-playing track. If you decide you don’t like it, disabling it is simple. Back in Terminal, type:

Shell
1
defaults delete com.apple.dock itunes-notifications

For ways to customise the pop-up, hit up the post linked below.

Posted: November 24th, 2011
Categories: Apple OSX
Tags:
Comments: No Comments.

Enable VNC/Management on OSX by SSH

I had the VNC based remote access feature of OS X enabled on 10.7 but somehow it got switched off.  I fiddled around a bit and figured out how to enable remote access from a remote SSH shell.  Note that these instructions will lead to manual configuration and you will not be able to enable/disabled the services from the System Preferences anymore.  In my case I used this to get in when I needed to but latter switched it back off and used the System Preferences setting.To manual switch on remote access from the terminal:
Shell
1
ssh username@mac_ip_address cd /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources sudo ./kickstart -activate -configure -access -on -privs -all -restart -agent
To switch this override back off and thus allow the System Preferences to manage screen sharing again run the following. (This will disconnect any active sessions and require physical access to re-enable it.)
Shell
1
sudo ./kickstart -activate -restart -agent
Posted: November 24th, 2011
Categories: Apple OSX
Tags: , ,
Comments: No Comments.

Change DeployStudio Wallpaper

I have been doing quite a bit of Mac OS X Image work lately and have found DeployStudio to be THE best FREE and easy to customise solution for doing this.

One thing i wanted to do was change the default wallpaper for the DeployStudioRuntime.nbi that is created and used as a windows Pre Environment equivalent.

I achieved this by going into the DeployStudioRuntime.nbi folder located on the server at:

Shell
1
/Library/NetBoot/NetBootSP0

I then mounted the ‘DeployStudioRuntime.sparseimage’ file and then navigated to the bellow folder inside the image and replaced the file ‘DefaultDesktop.jpg’ with my custom wallapper.

Shell
1
/System/Library/CoreServices

I made sure the image i created was a high res image to make it look nicer.

Posted: September 2nd, 2011
Categories: Apple OSX, DeployStudio, OS X Lion Server
Tags: ,
Comments: No Comments.