-
Notifications
You must be signed in to change notification settings - Fork 2
Vado and vamount
Hamish Mackenzie and I have been working on vado - a quick way to run commands on a remote ssh server. Just mount the directory you want to run the command in using sshfs, in that directory (or its subdirectory) run vado like this:
vado ls -l
vado will run 'mount' to identify the user account, server name and the remote directory to run the command in. It will then run ssh to connect to the server and run the command.
You can also pass ssh options like this:
vado -t htop
This tells vado to pass -t to ssh (forces pseudo-tty allocation and makes programs like vim and htop work nicely).
I will explain below how to set up vado for multiple remote servers/sshfs mount points and how to develop Haskell projects on a remote server/VM nicely using Emacs and ghc-mod.
Vado is not tied to vagrant, but can be used with it and is faster
than vagrant ssh
. If the user and host detected in mount
are
specified in the ~/.vadosettings
file, then the specified key and
port will be used.
The contents of the ~/.vadosettings
file is basically a Haskell
list of MountSettings
datastructures and we use standard Read
and
Show
type-classes for serialization.
The MountSettings
data type is defined as follows:
-- | Mount point settings
data MountSettings = MountSettings {
sshfsUser :: Text
, sshfsHost :: Text
, sshfsPort :: Int
, idFile :: FilePath
} deriving (Show, Read)
If the file is not present or incorrectly formatted then the default settings for vagrant will be used:
-
User: vagrant
-
Host: 127.0.0.1
-
Port: 2222
-
Key file:
~/.vagrant.d/insecure_private_key
An example settings file might look like this:
[
MountSettings {
sshfsUser = "vagrant"
, sshfsHost = "localhost"
, sshfsPort = 2222
, idFile = "/Users/dan/.vagrant.d/insecure_private_key"
},
MountSettings {
sshfsUser = "admin"
, sshfsHost = "server.local"
, sshfsPort = 2233
, idFile = "/Users/dan/keys/local_server_key"
}
]
Of course, using vado
requires mounting the sshfs beforehand. But
it gets tedious typing out
sshfs vagrant@localhost:/home/vagrant ../vm/ -p2222
-reconnect,defer_permissions,negative_vncache,volname=ghcjs,IdentityFile=~/.vagrant.d/insecure_private_key
every time. A tool called vamount
which is bundled together
with vado
can be used for mounting remote filesystems based on
~/.vadosettings
file.
You can use it like this:
vamount [ssh options] remote_path [profile #]
The remote_path
from the remote server specified in the
~/.vadosettings file under number [profile #] will be mounted in the
current directory using sshfs.
The profile number count starts from 1. If the [profile #] is absent or is 0 then the default (vagrant) configuration will be used.