fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] Creating a tunnel with Fabric


From: Taras Mankovski
Subject: [Fab-user] Creating a tunnel with Fabric
Date: Sun, 1 Nov 2009 23:32:37 -0500

Hey Guys,

What do you think about creating a function in Fabric that would allow
easy setup of a tunnel through ssh?

This would be very helpful for me because it would make it very easy
to for example connect to a remote MySQL server using my command line
MySQL client.

We could use a "with" context statement, something like:

with tunnel(local=3307, remote=3306):
     local('mysql --port=3007 --host=localhost' mydb < db/dbdump.sql')

This would eliminate the need to upload mysql dump file to the server
just to be able to run import.

Another application could be for administering Cherokee web servers.

Cherokee web admin by default is only accessible from the server that
it's running on. So you want to access the admin you have to tunnel
into the server and access the admin interface using a local port.
This could also be simplified with this functionality.

with tunnel(local=9090, remote=9090):
    sudo('cherokee-admin')
    prompt('Stop cherokee admin?')

That last line would keep the tunnel open until it's closed by providing input.

I think it's quiet elegant, what do you guys think?

Thank you,
Taras




reply via email to

[Prev in Thread] Current Thread [Next in Thread]