Topic: https://brettterpstra.com/2013/02/10/the-joy-of-sshfs/
hide preview

What's next? verify your email address for reply notifications!

Rich Cheng 11y, 346d ago

Thanks for this! Very cool.

One minor note: it's worth adding "follow_symlinks" to your sshfs command options, otherwise symlinks on the remote drive won't work correctly.

hide preview

What's next? verify your email address for reply notifications!

cceddie 11y, 350d ago

am I crazy or should the check in the rmount section:

> $(mount -- grep "mounts/$1")

be:

> $(mount | grep "mounts/$1")

specifically a pipe instead of the double dash.

remark link
hide preview

What's next? verify your email address for reply notifications!

ttscoff 11y, 350d ago

You're not crazy. I did a search and replace on the whole site to fix some table issues and that must have been caught in it. Fixing shortly.

hide preview

What's next? verify your email address for reply notifications!

Matthew H Glover 11y, 353d ago

I had trouble with mounting directories and getting an input/output error. I tracked it down (http://blogs.bu.edu/mhirsch... to needing a trailing slash. Once I did that, though, rmount would only use the hostname for the mount directory, not the remote directory name. I ended up changing:

mname=${folder##*/}
to
mname=`basename "$folder"`

hide preview

What's next? verify your email address for reply notifications!

Scott Bennett 12y, 34d ago

Thanks for the post. This looks like a really cool setup. Could you do (or have you done) a post where you talk more about how you use scp, rsync, and git to do your deployments in your 'ideal' scenario? I think that would be super helpful.

remark link
hide preview

What's next? verify your email address for reply notifications!

Phil 12y, 34d ago

I would like some insight on that as well. I've been trying to move me development group at work from svn to git. Simple deployments would help move that process along.

hide preview

What's next? verify your email address for reply notifications!

Mark Nichols 12y, 36d ago

And semi-related to the whole mount discussion, here's a nifty one-liner that displays what's mounted in a nice format.

# -------------------------------------------------------------------
# nice mount (http://catonmat.net/blog/an...
# displays mounted drive information in a nicely formatted manner
# -------------------------------------------------------------------
function nicemount() { (echo "DEVICE PATH TYPE FLAGS" && mount | awk '$2="";1') | column -t ; }

remark link
hide preview

What's next? verify your email address for reply notifications!

Brett Terpstra 12y, 36d ago

Took me a few tries, but that url in there should be http://www.catonmat.net/blo... if anyone wanted to know :). Thanks for the tip, that's a good one.

hide preview

What's next? verify your email address for reply notifications!

Mark Nichols 12y, 36d ago

I'm using zsh and when I add the rmount and remount functions to my .zshrc it objects to the `if [[ $2 ]]; then` line in the rmount function. Since it appears like this is only testing for the presence of a second parameter, I changed it to be `if [[ -n $2 ]]; then` where the `-n` returns true is the string is of non-zero length.

The rumount function also needs modifying on zsh. I added a `-d` to these four lines:
[[ -d $(mount|grep "mounts/$dir") ]] && umount ~/mounts/$dir       
[[ -d $(ls ~/mounts/$dir) ]] || rm -rf ~/mounts/$dir       
[[ -d $(mount|grep "mounts/$1") ]] && umount ~/mounts/$1       
[[ -d $(ls ~/mounts/$1) ]] || rm -rf ~/mounts/$1

`-d` returns true if the file exists and is a directory. 

As you note the rumount function is experimental I shall proceed with caution. 

Great article - I can see sshfs and these functions saving me lots of time and effort.

remark link
hide preview

What's next? verify your email address for reply notifications!

Brett Terpstra 12y, 34d ago

For web projects, the short version is that --- in my ideal scenario --- I use a bare git repository on the server as my 'origin' remote, and have a post-receive hook that runs something like:

GIT_WORK_TREE=/deploy/path/ git checkout -f

That takes the contents of the repo and exports a clean copy to the live site. I can use a few tricks to deploy branches of the repo to different locations to create staging sites from the same repo. Then I can just test locally, push to origin and have my site deployed (with version control).

I'm currently using rsync to deploy my Jekyll site from my work machine. That may change. Beyond that I primarily use rsync for backup and scp for quick transfers between servers of things like public SSH keys and config files.

There, that was kind of a post, right?

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Scott Bennett 12y, 33d ago

Sure, that counts. Just what I was looking for. Thanks for sharing.

Since I'm developing using the Grails framework right now, I'm stuck deploying WAR files to Tomcat (yikes). I'd love to be able to use something like rsync to just push up .class files that have changed when I compile but, I'm pretty sure I'm going to end up needing to use something like Jenkins/Bamboo in order to automate my deployments. 

I'll keep this workflow in mind though for other sites in the future.

Oh, and thanks for nvALT. It rocks.

hide preview

What's next? verify your email address for reply notifications!

Brett Terpstra 12y, 36d ago

I should have those test operators in there anyway, I'll update the script when I have a chance.

hide preview

What's next? verify your email address for reply notifications!

Phil 12y, 37d ago

Really cool tip, Brett! I'm hoping this might help me with some of the development I do on remote boxes. Currenlty I'm using Cyberduck+TextMate to "live" edit.

I'm running into issues with the sshfs-mounted directories though. When I try to save files in TextMate (v.2.0.0-alpha.9377, btw), I keep getting this error:

The document "fubar.php" could not be saved.

Setting extended attributes: Attribute not found

Some searching around seems to indicate this is an issue with some incompatibility with TextMate and fuse. Have you had this issue, and if so, any tips on getting around it?

Thanks again for this!

remark link
hide preview

What's next? verify your email address for reply notifications!

Brett Terpstra 12y, 36d ago

I haven't seen this issue, no, but it's likely a permissions conflict. Is it TextMate specific?

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Phil 12y, 36d ago

Not sure. Seems to be the only place I'm experiencing the issue. Or maybe TextMate is the only app that's griping about it. Apparently TextMate uses the extended file attributes to store metadata about the file, like bookmarks and text folding. And our linux servers don't seem to like it.

Odd thing is, the file actually gets saved, even though TextMate doesn't think so.

hide preview

What's next? verify your email address for reply notifications!

Thomas Kilgour 12y, 37d ago

Got through the entire set up with no problems, but when I try to run `rmount mm` (where `mm` is a server that I have set up properly in `~/.ssh/config`) I get this message:

    execl: No such file or directory

Any suggestions?

remark link
hide preview

What's next? verify your email address for reply notifications!

Brett Terpstra 12y, 37d ago

Not sure…

That error would typically mean that a binary wasn't being found, I think. If you run:

mkdir -p ~/mounts/mm && sshfs mm ~/mounts/mm -oauto_cache,reconnect,defer_permissions,negative_vncache,volname=mm,noappledouble

Does it throw an error?

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Thomas Kilgour 12y, 37d ago

It says:

missing hostsee `sshfs -h' for usage

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Brett Terpstra 12y, 36d ago

Just thought of this: what happens if you run the command above but with "user@hostname.tld" instead of the first mm? Does it connect fine then? That would indicate that sshfs isn't reading your .ssh/config file properly...

hide preview

What's next? verify your email address for reply notifications!

Brett Terpstra 12y, 36d ago

what if you run `ssh mm`?

remark link parent

load more (1 remarks)
hide preview

What's next? verify your email address for reply notifications!

Thomas Kilgour 12y, 36d ago

Yup, `ssh mm` works no problem.

remark link parent
hide preview

What's next? verify your email address for reply notifications!

Brett Terpstra 12y, 36d ago

well, something's up with your sshfs installation. Do you have other apps that use FUSE? Could be a conflict with varying versions of the FUSE library, but that's just a stab. You've pretty well narrowed it down to being an sshfs-specific issue, though… might check forums.

hide preview

What's next? verify your email address for reply notifications!