/kb

personal knowledgebase

Archive for the ‘ssh’ tag

SSH aliases

without comments

In ~/.ssh/config add the following:

Host ALIAS
HostName DOMAIN
User USERNAME
Port PORT_NUMBER

Written by hgrimelid

June 18th, 2010 at 10:02 am

Posted in Server,Shell

Tagged with ,

Passwordless login with MacFusion

without comments

Put a reference to the private key file in ~/.ssh/config, for example:

IdentityFile ~/.ssh/id_rsa

Source: FAQS.org

Written by hgrimelid

August 6th, 2009 at 9:28 am

Posted in Server

Tagged with , , , ,

Make SSHKeychain work in Leopard

without comments

Here’s how I set up SSHKeychain on my Mac:

  1. Modify the package content as described
  2. Add stuff to .bashrc/.profile
  3. Add keys to SSHKeychain: Preferences > SSH Keys
  4. Check Manage (and modify) global environment variables (this probably has no effect, ref 2.)

Written by hgrimelid

June 22nd, 2009 at 10:43 am

Posted in Shell

Tagged with , , , ,

Backing up my Macbook with rsync, SSH and Cron

without comments

I’ve created a simple script which syncs my documents folder with a remote computer. The files are transferred across the SSH protocol and the backup is performed daily with assistance of cron.

My rsync script is very simple:

#!/bin/bash
rsync -avzr --delete-excluded --exclude="*.log" --exclude="*.aux" --exclude=".svn" --exclude=".classpath" --exclude=".cache" --exclude=".project" --exclude="*.class" --exclude="*.swp" --exclude=".DS_Store" --exclude=".metadata" -e "ssh -c blowfish" /Users/USERNAME/Documents USER@REMOTE_COMPUTER:REMOTE_DIRECTORY

It was quite tricky to set up the cron job until i realized that cron does know very little of the user’s system. The trick was to add SSH_AUTH_SOCK=/tmp/501/SSHKeychain.socket in front of the script refrence in crontab, so that it looks like:

55 21 * * * SSH_AUTH_SOCK=/tmp/501/SSHKeychain.socket /Users/USERNAME/etc/backup.sh

This will cause the backup script to run at 21:55 each night. For more info on cron, check out unixgeeks.org. Add the following at the end if you’d like to suppress the mail from cron: >& /dev/null.

Note that for this script to run, SSH has to be set up with keypairs authentication.

Written by Håvard Grimelid

September 13th, 2008 at 11:29 pm

Posted in Scripts,Server

Tagged with , , ,

Simple scp script for copying to SSH enabled accounts

without comments

I frequently use scp to copy files to shell accounts. It’s quite annoying to type the full account info each time, so by writing a very small and very simple shell script some typing can be saved:

#!/bin/bash
scp -r "$1" login@server.domain.com:$2

The script copies file $1 to the destination $2 on the server. With -r option directories are copied as well. The “” are for taking care of file/directory names with spaces in.

Written by Håvard Grimelid

April 10th, 2008 at 9:37 am

Posted in Scripts

Tagged with , , , ,