Setting up a git server accessible via ssh

For small personal projects I often use git to track my work. Sometimes, I’ll work from a different computer and wish I could clone the repository and continue where I left off. I recently set up a git server that allowed me to do this and all I needed was ssh access.

Provided you have a remote server located at gitserver with user admin, you can set one up by doing the following.

Log in to your server and create the git user.
user@local $ ssh admin@gitserver
admin@gitserver $ sudo useradd -m git

Locally, create the ssh-key pair that you’ll using to log in to your server and copy it over.
user@local $ ssh-keygen -t rsa -f ~/.ssh/id_rsa_gitserver
user@local $ ssh-copy-id -f ~/.ssh/id_rsa_gitserver.pub git@gitserver

Create a placeholder for the repository that you want to track. --bare is used here because you’ll be pushing your current repo to the server.
user@local $ ssh -i ~/.ssh/id_rsa_gitserver git@gitserver
git@gitserver $ mkdir ~/repo.git
git@gitserver $ cd !$ && git init --bare

Push your local copy over to the server. Here, I start a new shell with ssh-agent so key management is handled transparently.
user@local $ ssh-agent bash
user@local $ ssh-add ~/.ssh/id_rsa_gitserver
user@local $ cd ~/repo
user@local ~/repo $ git remote add origin ssh://git@gitserver[:port]/home/git/repo.git
user@local ~/repo $ git push origin master

Finally, lock down the git account
user@local $ ssh admin@gitserver
admin@gitserver $ sudo chsh -s /usr/bin/git-shell git

As a general ssh security tip: make sure that password-based login is disabled and public-keys are required when logging in to the server.

Now you’re all set! You can push changes as usual by using git push.

Google’s addition of C class stock

This is a big announcement and I thoroughly expect it to be approved at the meeting this June.

Source: http://investor.google.com/corporate/2012/founders-letter.html
Related: http://investor.google.com/earnings/2012/Q1_google_earnings.html

Backing up your Gmail account using procmail and fetchmail

With the advent of tools such as Amazon EC2, backing up your mail accounts is relatively easily.

Before you begin, make sure that POP is enabled in your Gmail account. You will need to log in via the web interface to confirm these settings.

To get started, launch an instance on your favourite cloud provider (or alternatively on your own computer). It’s wise to create a new volume to store your data.

Rationale: Fetchmail is used to retrieve the mail and procmail is used to create a Maildir — a much preferable format for storing messages because each message is stored in a seperate file.

# Preparing the storage volume
sudo fdisk [disk location]
sync
sudo mkfs.ext3 [disk location]


# Mount storage volume

mkdir -p ~/mail.com/username
cd mail.com
sudo mount [disk location] ./username
sudo chown -R ec2-user:ec2-user username/

# Install packages
sudo yum -y install fetchmail ca-certificates procmail

# Confirm that SSL connection works
openssl s_client -connect pop.mail.com:995
You should see Gpop ready for requ….

# Configure fetchmail
vim ~/.fetchmailrc

poll pop.mail.com
service 995
protocol pop3
username username@mail.com
password ‘password’
options ssl

# Configure procmail
vim ~/.procmailrc

MAILDIR=$HOME/mail.com/
LOGFILE=$HOME/pm.log
VERBOSE=on

:0
username/


# Change ownership

chmod 600 ~/.fetchmailrc ~/.procmailrc

# Confirm that the configuration works
fetchmail -vk
C-c

# Download the mail
fetchmail -nk -a -d 200 -N

If you have a large mailbox, as expected, this will take a while. After it’s done, consider storing a copy of this volume (if using a cloud provider) elsewhere.

Quickly Attaching USB Devices to VirtualBox Guests using VBoxManage

I frequently develop inside VBox guests because I to ensure that my development environment is consistent across machines and operating systems.

Sometimes, I will need to connect a USB device plugged into the host computer to the guest VM. Because I start most VMs in headless mode, I would rather not launch the VM manager just to attach the USB device. Using VBoxManage, you can also mitigate this issue.

First (if you do not remember), find the name of the VM.
$ VBoxManage list vms
"archlinux" {3daf7395-3866-2348-bc54-947445b5e626}
[truncated]

List the USB devices attached to the host.
$ VBoxManage list usbhost
UUID: e2d15ede-83f1-45ad-98d5-1efa46b810eb
VendorId: 0x06c2 (06C2)
ProductId: 0x0033 (0033)
Revision: 1.0 (0100)
Manufacturer: Phidgets Inc.
Product: PhidgetSpatial
SerialNumber: 166112
Address: p=0x0033;v=0x06c2;s=0x000064bfc79cb786;l=0x06200000
Current State: Captured

Note that if the Current State is Captured, then you should make sure that the host has not already locked the device. In this case, it was already captured by the guest.

Connect the USB device to the guest, using the given UUID.
$ VBoxManage controlvm archlinux usbattach e2d15ede-83f1-456d-98d5-1efa46b810eb

You can also make this attachment permanent by creating a USB filter.

List the filters for the VM. Note the index.
$ VBoxManage showvminfo archlinux
USB Device Filters:

Index: 0
Active: yes
Name: Phidgets Inc. PhidgetSpatial [0100]
VendorId: 06c2
ProductId: 0033
Revision: 0100
Manufacturer: Phidgets Inc.
Product: PhidgetSpatial
Remote: 0
Serial Number: 166112

Place the filter after the last index. You can grab the VendorId and the ProductId from the previous usbhost output.
$ VBoxManage usbfilter add 1 --target archlinux --name Phidget --vendorid 0x06C2 --productid 0x0033

If you have problems setting the filter, first ensure that there are no existing global filters.
$ VBoxManage list usbfilters

You can later remove the filter by using a similar incarnation.
$ VBoxManage usbfilter remove 1 --target archlinux

Predictions for iOS 5

Here is a short list of the things that I think will be present in iOS 5. The correct featureset will be announced at the 2011 WWDC.

  1. Improved notification infrastructure, i.e., like the jumping dock present in Mac OS.
  2. Storage of contacts/documents/mail/calender events/books/purchased songs and videos on the cloud with no intervention and no limit
  3. Improved support for exchange and corporate infrastructure
  4. Group messaging
  5. Dynamic homescreen tiles
  6. Universal search
  7. New animations for common actions
  8. Support for at least 10 more languages (I would say 20 new languages)
  9. Improved iTunes/iPod experience
  10. Improved lock screen
  11. Font/kerning updates
  12. Improved accessibility
  13. Maps improvement

HP Veer

I have been thinking about a phone with a small but usable form factor for a long time. Microsoft nailed it with the Kin but unfortunately the target audience was not applicable to me. I’m really excited about the HP Veer which is supposed to be shipping in the spring.

The deciding factor is the answer to the question: how much for an unlocked phone? It is only running a Snapdragon 800Mhz CPU and given that the screen is a little over 2 inches, I don’t see why it would cost much more than $399.

Time will tell.

Link: “HP Veer, first hands-on! (updated with video!)” [http://www.engadget.com/2011/02/09/hp-veer-first-hands-on/]

Getting Started with Symbian Development

The world has gone app-crazy and I want to become a part of it. I’ve decided to see if I can horne my C++ skills by creating a Symbian application.

Getting prepared for Symbian development isn’t a straightforward process. Here’s how I set up my development environment:

Download and install ActivePerl (current version is 5.10.1).

I’m developing for the Symbian S60v3 FP1 platform so I needed to apply the context sensitive patch.

Download and install the JDK (current version 6u20).

Download and install the Carbine.c++ development environment (current version 2.3).

For Windows XP SP3 (and probably SP2) users, add the epoc.exe binary to the allowed DEP. You can do this by going to Start -> right click on My Computer -> click on Properties -> click on the Advanced tab -> click on Settings in the Performance category -> click on the Data Execution Prevention tab -> select the “Turn on DEP for all programs and services except those I select:” radio button -> click Add -> Navigate to C:\Symbian\9.2\S60_3rd_FP1\Epoc32\release\winscw\udeb and select epoc.exe (location is dependent on installation path).

Finally, install the S60 Platform SDK. I selected 3rd Edition, FP 1.

Further instructions are available at the Forum Nokia Library.

Printing to a remote printer

Every now and then I’ll enter the computer lab only to find that all the computers are being used – this usually happens when I urgently need to print something before I miss the bus.

Thankfully, the system admins have allowed me the wonders of ssh access. So, printing is relatively simple:

Copy the file to be printed to the server.

scp filename.pdf username@server:.

List all available printers.
lpstat -a

Send your document to the printer.
lpr -Pprinter filename.pdf

Optionally, to save paper, you may print multiple pdf pages on one sheet.
The process is simple: convert the pdf to ps (postscript), use the psnup utility to increase the number of pages placed on each sheet, then convert the pdf to ps.

pdf2ps filename.pdf
psnup -n2 filename.ps (or 2up filename.ps to get two pages per sheet)
ps2pdf filename.ps

KDE DPI Issue

Simple fix:

in /usr/share/config/kdm/kdmrc

Add the “-dpi ” argument to ServerArgsLocal in [X-:*-Core].

Not sure what this does to dual monitor setups.

Sony NWZ-E438F + Video

I recently purchases a Song Walkman which has great video capabilities – provided you know how to encode the video.

It’s not very hard, simply chuck the video into handbrake and let it churn out a Sony Walkman compatible video:
handbrake -i $input_name -o $output_name.mp4 -f mp4 -e ffmpeg -E faac -w 320 -l 240 -b 500

If you don’t have this program, use the following options in any video converter program:
width: 320px
height: 240px
audio encoder: faac
video encoder: ffmpeg
output format: mp4
video bitrate: 500 kb/s

Follow

Get every new post delivered to your Inbox.