Accessing git over ssh on a non-standard port

Simple ssh access to a git repo can be sufficient for a small dev team–but what if you’re using a non-standard ssh port?

The solution–do as Linus says. Use ~/.ssh/config.

My config now looks like this:

Host my.servername.org
  Port 1234

Remember that ~/.ssh needs to be 700 (read/write/execute for only the owner), and the files inside are all 600:

$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/*

Installing git with MacPorts

The Good: MacPorts makes git, the new source version control system hotness, available to Mac users.

The Bad: MacPorts sometimes has attitude, and poops out trying to compile or install packages.

The Ugly: MacPorts doesn’t tell you how to fix it.

So here was what I saw:

mrm@whack:~$ port search git
cogito     devel/cogito   0.18.2   Git core and cogito tools to provide a fully-distributed SCM
git-core   devel/git-core 1.6.0.4  A fast version control system
qgit       devel/qgit     2.2      A graphical interface to git repositories
stgit      devel/stgit    0.14.3   Push/pop utility on top of GIT
cgit       www/cgit       0.8      A fast web interface for the git source code management system

Great. I’ll install git-core. What additional goodies are there?

mrm@whack:~$ port info git-core
git-core 1.6.0.4, devel/git-core (Variants: universal, doc, gitweb, svn, bash_completion)

http://git.or.cz/

Git is a fast, scalable, distributed open source version control system focusing on speed and efficiency.

Library Dependencies: curl, zlib, openssl, expat, libiconv
Runtime Dependencies: rsync, perl5.8, p5-error
Platforms: darwin
Maintainers: bryan@larsen.st maccheck@gmail.com openmaintainer@macports.org

OK, so I want svn and doc and bash_completion extras:

mrm@whack:~$ sudo port install git-core +svn +doc +bash_completion +gitweb
...
Error: Target org.macports.fetch returned: fetch failed
Error: The following dependencies failed to build: p5-svn-simple subversion-perlbindings subversion p5-term-readkey rsync popt
Error: Status 1 encountered during processing.

So we’re now at the bad and ugly. When ports cops attitude, run these two commands:

sudo port selfupdate
sudo port upgrade outdated

and wait. If there are any failures, look at the package that failed, and restart the installation of that package. Once that’s completed, re-do the original port install git ... command.

Make OpenOffice the default “.doc” and “.xls” application on Mac OS X

OpenOffice 3.0 is now out for the Mac. Finder opens files that end in “.doc” with TextEdit by default, and “Open with…” doesn’t seem to stick. What to do?

  1. In the finder, find a file that ends in “.doc”,
  2. Click once to select it
  3. Choose File > Get Info...
  4. Find the “Open with:” section, and click the triangle to show the contents of that section.
  5. Choose OpenOffice
  6. Click “Change All…”

You’ll probably want to do this with .ppt, .xls, and .csv, too.

It was an odd choice to put the system-default web browser in a Safari preference pane and make other file types second-class citizens. Why not be consistent and make a System Preference pane for default applications?

Free and Easy Encrypted Storage for Mac OS X and MobileMe or DropBox

Online storage services like iDisk (part of MobileMe) or DropBox are very convenient for sharing and backing up files–but when you put files into the cloud you’re assuming that:

  • those companies, and
  • all their employees, and
  • all their contractors, and
  • all their collocation facility employees

will be morally upstanding. And that they will securely erase old drives. And that their systems will never be cracked. Ever.

My point is that sensitive stuff, like tax documents and passwords, must be encrypted before storing them in the cloud.

The solution? Make an encrypted file on your computer that can be mounted as a “secure hard drive”.

(Update August 2009): TrueCrypt is an easy-to-use and cross-platform solution to this issue. The following is a tutorial that is a Mac OS X specific alternative to TrueCrypt.

Example disk image

Example disk image

Using the disk image is easy — when you double click your encrypted disk image, you’ll be prompted for the image’s password, and then the image will be mounted, looking just like another hard drive was attached to your computer. (With TrueCrypt you must “mount” the file using the TrueCrypt software, so it isn’t quite as user-friendly).

You can drag-and-drop private files into the disk image, and even edit them just like a normal disk. When you’re done, eject the drive, and your files won’t be readable until the image’s password is re-entered.

The disk image can be stored on your MobileMe drive for backups, but you make sure you un-mount/eject the drive before you lose your network connection to prevent the disk image from losing your most recent changes.

So — here’s how to create one of these encrypted disk images.

Mac OS X Disk Utility

Mac OS X Disk Utility

  1. Open Disk Utility (found in /Applications/Utilities/)
  2. Click “New Image” in the toolbar
  3. The “Save As:” field will be the name of the disk image file, so it should be something like “secret.dmg” or “private.dmg.”
  4. The “Volume Name:” is what the name of the disk will be when it’s mounted.
  5. A volume size of 100 MB should be fine if you’re just storing documents–and you can resize the image later if you need to.
  6. Choose Mac OS Extended (Case-sensitive, Journaled)
  7. Choose 256-bit AES encryption
  8. Choose No partition map
  9. Choose read/write disk image
  10. And finally click Create
Settings in Disk Utility to create an encrypted disk image

Settings in Disk Utility to create an encrypted disk image

I’d recommend NOT storing the password in your keychain, so when asked for the password for the disk image, unselect that option, and make sure you remember the password to your new image–because you can’t open it without the password.

Disk Utility will automatically mount the disk image as soon as it’s created. Remember to eject it when you’re done (by right-clicking on the disk image and choosing “Eject”). In the future double-click the image to re-mount it and get access to your secret files again.

Make “ps -ef” work in a shell on Mac OS X

If you’re used to SunOS or BSD, you’ll be at home with Mac OS X’s “ps -aux” to get a process list from a shell prompt.

If you’ve been using any other recent unix, though, your fingers will want to type ps -ef instead. Rather than hack an alias to wrap ps to make this happen, it turns out there’s an easy way to return to the ps promised lands.

By default on Mac OS X 10.5.2, the shell environment’s COMMAND_MODE is set to legacy. If you set it to unix2003, you’ll get your ps -ef. Just add

export COMMAND_MODE=unix2003
alias zcat='gunzip -c'

to your ~/.bashrc to make it be set automatically.

The alias of zcat to gunzip -c fixes a “feature” in unix2003 mode — it removes gzip support from zcat. If you’re used to using zcat for both compressed .Z files as well as gzipped .gz files, you want the alias line as a workaround.

“Backing up iPhone” taking forever? Reset iSync!

Update 9/14/2008:

Backup speed was addressed in iPhone software version 2.1. Launch iTunes, dock your iPhone, and click “Check for Update”.

And now back to the original article:


I was surprised to see my brand-new iPhone 3G taking more than 15 minutes to synchronize with iTunes. It would get “stuck” in “Backing up iPhone…”

It looks like there are two reasons why the backup process takes longer — iTunes backing up newly-installed applications, and MobileMe/iSync database cruftiness. Expect sync’ing to take a while if you’ve installed new applications. If you haven’t installed new applications, you should try resetting the iSync database.

It’s pretty simple:

  1. Close iTunes.
  2. Start iSync
  3. Click iSync > Preferences.
  4. Click “Reset Sync History…

The next time you sync with iTunes, the “Backing up” step should be dramatically shorter.

Another interesting solution involves Vacuuming your syncdb. If you’ve got MacPorts installed, it’s easy:

sudo port install sqlite3
sqlite3 \
  ~/Library/Application\ Support/SyncServices/Local/data.syncdb\
  vacuum

MobileMe Family Pack looks like an “individual” subscription

I just signed up for MobileMe and bought the family pack — when I activated the account, though, it looked like I had an “individual” subscription, not a “family” subscription.

Their terminology is pretty confusing to the casual observer.

If you buy a “Family Pack”, you’re really buying one “individual” account as well as four “family” accounts. The account that you activate MobileMe with will be the “individual” account that has the 20GB of storage (so choose the username carefully).

To activate the family accounts, first click the account tab (the far right button), then click “Account Options.” You’ll see this:

There’s several scary red things saying stuff is going to expire, and credit card billing information missing. You’re supposed to intuit that the tiny “(Set Up Account…)” link is what you’re supposed to click to add your 4 family accounts:

This experience was not pleasant. Nebulous terminology mixed with user experience mistakes will cost Apple a lot of support calls and emails.

50,000 photos in iPhoto on a shared laptop and external drive

I’ve got over 100GiB of photos (JPEG and RAW) taken over the years, and they don’t comfortably fit on a laptop. The laptop is also shared by everyone in my family, each with their own account, so what to do?

I found out that if you hold down the option key when you start iPhoto it asks for the location of your iPhoto Library — so that takes care of the first problem — just plug in a big external hard drive and you’re set.

There’s one glitch to having the photos on an external drive, though — Time Machine ignores exernal drives by default. Go into System Preferences… > Time Machine. Click “Options”. You’ll see your external drive in the “Do not back up:” list. Click the external drive holding your photos, then click the minus button.

The next problem is how to share the library with others. That’s described quite well by a Mac OS X Hint. Note that the following assumes you’ve named your external hard drive “Photos”.

Step 1: Enable ACLs:

sudo fsaclctl -p /Volumes/Photos -e

Step 2: Add the people that can use iPhoto. Replace “USERNAME” with the short login name of the people that you want to be able to use iPhoto:

sudo chmod +a "USERNAME allow read,write,delete,list,search,add_file,add_subdirectory,delete_child,file_inherit,directory_inherit" \
  /Volumes/Photos/iPhoto\ Library

Creating a group account, subscribing the users to that group, and letting group have read/write/execute to the directory should work, but the umask may not be 775. It’s something to check if this doesn’t keep working.

Ant bash completion on Mac OS X

bash will do tab-completion for ant targets on Debian/Ubuntu boxes out-of-the-box. If you haven’t upgraded lately, you may need to:

sudo apt-get install bash-completion

On Mac OS X, it needs a bit of massaging. First install the macports version of bash-completion and ant:

sudo port install bash-completion apache-ant

Then add this to the end of your ~/.bashrc:

if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
complete -C /opt/local/share/java/apache-ant/bin/complete-ant-cmd.pl ant

See http://marius.scurtescu.com/2005/03/23/ant_bash_completion for Windows instructions.