Posts tagged as:

Linux

Keep in sync two hosts on Internet using LFTP

by Roberto on April 21, 2009

in Work

There are many softwares and solutions that permit to keep in sync two or more hosts (like Rsync, Unison, etc), but when the sync must be made through Internet and you have access only to the ftp or http service your choices narrow down. This is the typical situation you can face on a shared hosting solution.
A great solution to synchronize two directories on different hosts through ftp or http protocol is LFTP :

LFTP is sophisticated ftp/http client, file transfer program supporting a number of network protocols. Like BASH, it has job control and uses readline library for input. It has bookmarks, built-in mirror, can transfer several files in parallel. It was designed with reliability in mind

LFTP has many useful features, like :

  • FISH and SFTP protocols support
  • Built-in mirror and reverse mirror (mirror -R)
  • Job queueing
  • Job execution at specified time
  • Comprehensive scripting support
  • FXP transfers support (between two FTP servers, bypassing client machine)

See the complete list of features

To keep in sync two directories on two hosts on Internet you need to create a little shell script and set a cron job for it on one host and create an ftp access on the other host.
For example for BASH shell :

#!/bin/bash
#Synchronization script
lftp -u [remote username],[remote password] [remote host] <<EOF
set ftp:ssl-allow no
mirror [remote directory to sync] [local directory to sync]
quit 0
EOF

Parameters :

  • [remote username] : remote ftp username
  • [remote password] : remote ftp password
  • [remote host] : remote hostname or ip address
  • [local directory to sync] : local directory to synchronize
  • [remote directory to sync] : remote directory to synchronize

Other resources : LFTP manual, LFTP tutorial

{ 5 comments }

Using a server service through a SSH tunnel

by Roberto on April 20, 2009

in Work

If you have access to a server only through SSH, you can yet access all the others server services without the need to forward other ports on the router or firewall.
Here is how :

  1. Open a console on your client
  2. Type : ssh -L [local port]:localhost:[remote port] [username]@[remote server]

From now on you can reach the remote service accessing to localhost on port [local port].

Parameters :

  • [local port] : the port you'll use on your client
  • [remote port] : the port you need to reach on the remote server
  • [username] : your username on the remote server
  • [remote server] : remote server public hostname or ip address

So, for example, if you want to access the webserver running on the remote server on the port 80, you'll write :
ssh -L 8080:localhost:80 [username]@[remote server]

Opening in your browser the url http://localhost:8080 you'll be able to access the remote webserver.

A similar solution can be implemented using Zebedee that doesn't require a SSH access because has its own authentication and encryption routines.


{ 0 comments }