Notes on sshfs on Ubuntu
sshfs is an easy way to mount a remote filesystem using ssh and FUSE. If your remote server is already running a ssh server that supports sftp (Ubuntu's ssh server does), there is nothing to set up on the remote server and set up on the client is relatively easy.
Other options for mounting a remote filesystem are WebDAV, Samba, and NFS. I'm no expert, but from what I've gathered, sshfs is faster than WebDAV and slower than Samba and NFS. However, Samba and NFS are typically more difficult to set up than sshfs. Here are my ...
... read more »Python paramiko notes
Paramiko is a Python ssh package. The following is an example that makes use of my ssh config file, creates a ssh client, runs a command on a remote server, and reads a remote file using sftp. Paramiko is released under the GNU LGPL
Install paramiko
- Install pip
- Install paramiko
sudo pip install paramiko
Example
from paramiko import SSHClient, SSHConfig
# ssh config file
config = SSHConfig()
config.parse(open('/home/saltycrane/.ssh/config'))
o = config.lookup('testapa')
# ssh client
ssh_client = SSHClient()
ssh_client.load_system_host_keys()
ssh_client.connect(o['hostname'], username=o['user'], key_filename=o['identityfile'])
# run a command
print "\nRun a command ...A hack to copy files between two remote hosts using Python
I sometimes need to copy a file (such as a database dump) between two remote hosts on EC2. Normally this involves a few steps: scp'ing the ssh keyfile to Host 1, ssh'ing to Host 1, looking up the address for Host 2, then scp'ing the desired file from Host 1 to Host 2.
I was excited to read in the man page that scp can copy files between two
remote hosts directly. However, it didn't work for me.
Apparently,
running scp host1:myfile host2: is like running
ssh host1 scp myfile host2: so I still need ...
Wmii Python script to monitor remote machines
I like to monitor our web servers by ssh'ing into the remote machine and watching "top", tailing log files, etc. Normally, I open a terminal, ssh into the remote machine, run the monitoring command (e.g. "top"), then repeat for the rest of the remote machines. Then I adjust the window sizes so I can see everything at once.
My window manager, wmii, is great for tiling a bunch of windows at once. It is also scriptable with Python, so I wrote a Python script to create my web server monitoring view. Below is my script. I also put ...
... read more »Notes on Python Fabric 0.9b1
Fabric is a Python package used for deploying websites or generally running commands on a remote server. I first used Fabric about a year ago and thought it was great. Since then, Fabric has procured a new maintainer, a new domain, and a few new revisions.
Here are my notes on installing the latest stable version (0.9b1) on Ubuntu Jaunty and running a simple example.
Install Fabric 0.9b1
- Install Easy Install & pip
sudo apt-get install python-setuptools python-dev build-essential
sudo easy_install -U pip
Install Fabric
Note: According to the Fabric website, the latest version of the prerequisite Python library ...
Creating remote server nicknames with .ssh/config
Using the ~/.ssh/config file is an easy way to give your
remote machines nicknames and reduce the number of keystrokes needed
to login with ssh, rsync,
hg push/pull/clone, access
files via Emacs Tramp
(Transparent Remote (file) Access, Multiple Protocol),
or use any other SSH-based tool. You can also set other ssh options such
as IdentityFile, Port, or CompressionLevel.
For more information and a full list of options, check out the man page for ssh_config or
this article
by Kimmo Suominen.
Here is part of my ~/.ssh/config file. It defines the
nicknames turk, tyran, tuna, and tally ...
Notes on Python deployment using Fabric
I found out about
Fabric via Armin Ronacher's article
Deploying Python Web Applications.
Fabric is a
Capistrano inspired
deployment tool for the Python community. It is very simple
to use. There are 4 main commands: local is
almost like os.system because it runs a command
on the local machine, run and sudo
run a command on a remote machine as either a normal user
or as root, and put transfers a file to a remote
machine.
Here is a sample setup which displays information about the Apache processes on my remote EC2 instance.
- Install Easy Install
- Install Fabric ...
About
I'm Eliot and this is my notepad for programming topics such as Python, Django, Ubuntu, Emacs, etc... more »
Search Blog
Tags
-
algorithms
(4)
-
aws
(8)
-
blogproject
(20)
-
c_cplusplus
(12)
-
cardstore
(8)
-
colinux
(2)
-
concurrency
(9)
-
conkeror
(2)
-
cygwin
(18)
-
datastructures
(15)
-
datetime
(3)
-
dell
(3)
-
django
(39)
-
emacs
(20)
-
files_directories
(10)
-
install_setup
(7)
-
javascript
(3)
-
keyboard
(6)
-
matplotlib
(5)
-
mercurial
(4)
-
nginx
(2)
-
preferences
(8)
-
processes
(3)
-
pyqt
(18)
-
python
(122)
-
ratpoison
(3)
-
regexes
(5)
-
rsync
(3)
-
softwaretools
(17)
-
sql
(13)
-
ssh
(7)
-
subversion
(6)
-
twisted
(6)
-
ubuntu
(60)
-
urxvt
(5)
-
vxworks
(25)
-
webservices
(4)
-
wmii
(7)
Blogroll
- Adam Gomaa
- Alex Clemesha
- Amir Salihefendic
- Armin Ronacher
- David Beazley
- David Ziegler
- Duncan McGreggor
- Gareth Rushgrave
- Glyph Lefkowitz
- Guido van Rossum
- Ian Bicking
- Jacob Kaplan-Moss
- James Bennett
- James Tauber
- Jesper Noehr
- Matt Harrison
- Nikolay Kolev
- Parand Darugar
- Peter Baumgartner
- Peter Bengtsson
- Rob Hudson
- Simon Willison
- Will McGugan