Archive for the ‘ssh’ Category

Using ssh forwarding to retrieve papers instead of VPN

November 5, 2008

So far I was using VPN to connect to my university network when I needed to download a paper from home, but that meant to temporarily lose my network connection, with all the hassle attached.

Today I discovered a much simpler method:

1) Open a ssh port forwarding to the remote machine (university server with IEEE or ACM subscription) in this way:

ssh -D 8080 -N <username>@<server address> &

where -D indicated the local port to forward, and -N avoid opening a shell.

2) Download the FoxyProxy Firefox extension, and configure in order to use a proxy on localhost:8080.

3) Add rules to FoxyProxy so that the proxy is active only when needed (*.ieee.*, *.acm.* etc…).

Thanks to Timo Reimann for having suggested that.

Advertisements

Download papers via SSH

January 11, 2008

Want to download a paper from home, or from a poor different university which doesn’t have all subscriptions? Try this paper-get script.

Usage: paper-get URL [filename]

#!/bin/sh

SSH_TARGET=user@mymachine

if [ -n "$2" ]; then
    DEST="$2"
else
    DEST="$(basename $1)"
    echo Saving to $DEST
fi

if [ -e "$DEST" ]; then
   echo Warning: the destination file already exists.
   echo Press Enter to overwrite, Ctrl-C to abort.
   read ANTANI
fi

ssh $SSH_TARGET wget -O- \"$1\" > "$DEST"

Public Key Authentication from OpenSSH to SSH

December 19, 2007

I set up public key authentication from my machine to a couple of other machines. This is quite handy since you only need to provide your passphrase once and then the ssh agent does the authentication for you. However, I could not figure out why my key was not working with a particular server until I found out that there are differences between OpenSSH and SSH. To use your OpenSSH key with an SSH server, you need to convert it first and then put it in a specific place. Here a step by step tutorial, that I found here.

  1. Change to your local .ssh directory
    cd ~/.ssh
  2. Convert your public key
    ssh-keygen -e -f id_dsa.pub > id_dsa_secsh.pub
  3. Copy this new key to the remote machine into the .ssh2 directory
    scp ~/.ssh/id_dsa_secsh.pub chris@remotemachine:~/.ssh2/
  4. SSH into the remote machine
    ssh chris@remotemachine
  5. Append information to the .ssh2/authorization file
    echo Key id_dsa_secsh.pub >> .ssh2/authorization

That’s it! From now one, “ssh remotemachine" will be enough.

A simple SSH config file

December 17, 2007

You can provide ssh with a config file if you’re connecting to many different machines with different ports, user names etc.

Create a file called “config” in your .ssh directory on your machine. This file can contain entries such as

Host Home
User chris
Port 8888
HostName chrisonline.com

Host Office
User myseriousname
Port 22
HostName machine.atwork.com

What you can do then is just type “ssh Home”and ssh will automatically pick the right user name, machine and port. This is very convenient if you have different user names on different machines. I found this information here.