Category Archives: Linux

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 -L 5000/localhost/7000

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/

SSH Keys

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

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

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

How to synchronize two folders in linux

this days I’ve discover a very good command in linux : rsync

rsync -avHP  --numeric-ids --delete null/images/  /var/lib/jetty6/webapps/images/
-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
    --no-OPTION             turn off an implied OPTION (e.g. --no-D)
-v, --verbose               increase verbosity
-H, --hard-links            preserve hard links
-P                          same as --partial --progress

With this option rsync will transfer numeric group and user IDs rather than using user and group names and mapping them at both ends.
By default rsync will use the username and groupname to determine
what ownership to give files. The special uid 0 and the special group 0 are never mapped via user/group names even if the --numeric-ids option is not specified.
If a user or group has no name on the source system or it has no match
on the destination system, then the numeric ID from the source system is used instead. See also the comments on the lquse chrootrq setting in the rsyncd.conf manpage for information on how the chroot setting affects rsync's ability to look up the names of the users and groups and what you can do about it.
This tells rsync to delete extraneous files from the receiving side (ones that aren't on the sending side), but only for the directories that are being synchronized. You must have asked rsync to send the whole directory (e.g. lqdirrq or lqdir/rq) without using a wildcard for the directory's contents (e.g. lqdir/*rq) since the wildcard is expanded by the shell and rsync thus gets a request to transfer individual files, not the files' parent directory. Files that are excluded from the transfer are also excluded from being deleted unless you use the --delete-excluded option or mark the rules as only matching on the sending side (see the include/exclude modifiers in the FILTER RULES section).