Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
mounting_ssh_with_sshfs [2008/11/20 15:16]
127.0.0.1 external edit
mounting_ssh_with_sshfs [2020/06/01 22:53] (current)
Line 1: Line 1:
 +====== Mounting SSH with sshfs ======
  
 +You can mount an SSH connection with sshfs.
 +
 +  sshfs <​user>​@<​server>:<​remote_path>​ <​local_mount_point>​
 +
 +You can unmount it with:
 +
 +  fusermount -u <​local_mount_point>​
 +
 +Here's a shell script I use to mount and unmount several servers that I connect to frequently.
 +
 +<​code>​
 +#!/bin/bash
 +
 +# Get a count of files on the stage server
 +dirCount=`ls /mnt/Stage/ -a -1 | wc -l`
 +
 +# If unmount was specified
 +if [ "​$1"​ == "​-u"​ ] ; then
 +
 + # Check if there are more files than an empty directory
 + if [ $dirCount == 2 ]; then
 + echo KSL servers are not currently mounted.
 + exit
 + fi
 +
 + # Unmount the volumes
 + echo Unmounting KSL servers
 + fusermount -u /mnt/Data
 + fusermount -u /​mnt/​Pandora
 + fusermount -u /mnt/Stage
 + fusermount -u /mnt/Nest
 +
 +else
 +
 + # Check if there are more files than an empty directory
 + if [ $dirCount != 2 ]; then
 + echo KSL servers are already mounted.
 + exit
 + fi
 +
 +  # Mount the systems
 + echo Mounting servers
 + sshfs root@data.example.net:/​ /mnt/Data
 + sshfs root@pandora.example.net:/​ /​mnt/​Pandora
 + sshfs root@stage.example.net:/​ /mnt/Stage
 + sshfs root@nest.example.com:/​ /mnt/Nest
 +
 +fi
 +
 +exit
 +</​code>​
comments powered by Disqus