Creating a tunnel using ssh

If you want to forward a port to your computer from another, and you can create a ssh connection to the computer, then creating the actual tunnel is very simple.

This exemple forwards the port 7000 from that computer to a port on our computer. In this case the local port in 5000

ssh -N -p 22 user@www.server.com -L 5000/localhost/7000

How to edit the hosts file on Mac OS X

The hosts file in a computer represents a simple plain text file, where are mapped hostnames to IP addresses (wiki).

To edit this file on Mac OS X is a very simple task:

  • Open the Terminal.app 
    (using Spotlight : command + space  – and then write terminal)
  • Edit the file /private/etc/hosts
    (you can use vim or nano …. ex: sudo nano /private/etc/hosts)
  •  Add the new map:
    add at the end the new map you want : ex: 127.0.0.1         new.address.com
  • Save the hosts file
    save the file with the new map

If you want that your change to take place immediately, run the following command:

  • dscacheutil -flushcache

Now you can test the new mapping.

How to generate an openssh-key from a key generated by putty? (on Debian)

This was the problem that I faced these days; and the answer to it is very simple

First thing you have to do is to install putty tools in linux :

$app-get install putty-tools

Then, just generate the new private key, using puttygen program

$puttygen putty-generated-key.ppk -O private-openssh -o openssh-key-name

You see, everything is very simple.

Also, if you want to generate the public key, you can use the following command:

puttygen ‐L putty-generated-key.ppk >> authorized-key-location/public-key.pub

SSH Keys

Some useful commands in “linux” to generate a public key from a private one.

ssh-keygen -f ~/id_rsa -y > ~/id_rsa.pub 

if you receive some warnings regarding users permissions about the private key file, the easiest way is to run the following command

chmod 700 id_rsa