Automatic mount via sshfs

Hello guys,
I set up sshfs using the /home directory of my server and mounting it on /mnt/server. I had to configure the directory permission but now I'm able to mount the directory as normal user with that command:
sshfs user@serverip:/home/user /mnt/server
The next step I tried was to mount my server directory automatically using the fstab method from the wiki. So I added
sshfs#user@serverip:/home/user /mnt/server fuse defaults 0 0
to my fstab, rebooted my system but nothing was mounted. What's wrong? I have to add that I already set up a SSH Key.
Best regards.
Last edited by orschiro (2009-06-20 00:01:55)

I have ssh-agent setup to ask for my passphrase on the first login after I bootup the machine. This works quite well, and then I don't have to worry about passphrase entry for automated ssh/rsync backups, or logging in to my server for whatever.
in ~/.bashrc --
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
else
start_agent;
fi
The code isn't mine, but pieced together from several tutorials (don't remember where!) I believe this is basically the same thing that, for example, the gnome-keyring does when it asks for your keyring password. Just doing it the lightweight KISS way
Good luck!
Scott
Last edited by firecat53 (2009-06-20 22:04:35)

Similar Messages

  • [Solved] sshfs can't mount via fstab on startup

    I have an HDD mounted in my RPI which I've mounted as a filesystem in my desktop via sshfs (through fstab).
    If I do "sudo mount -a", it seems to mount just fine, so I researched a bit (even though I'm still an newbie in Arch and Linux distros in general) and found out that it's most probably is caused due to the network not being initialized fast enough for the sshfs fstab entry to be discovered (due to having no network and therefore no access to it).
    I'm really not sure how to provide any info which would help you guyz help me so I'm just gonna provide the sshfs entry from my fstab file and the journalctl logs that seem to be relevant.
    Jun 23 22:32:00 home systemd[1]: home-username-media-downloads-mydrive.mount mount process exited, code=exited status=1
    Jun 23 22:32:00 home systemd-udevd[168]: renamed network interface eth0 to enp0s25
    Jun 23 22:32:00 home systemd[1]: Failed to mount /home/username/media/downloads/mydrive.
    Jun 23 22:32:00 home systemd[1]: Dependency failed for Remote File Systems.
    Jun 23 22:32:00 home systemd[1]: Unit home-username-media-downloads-mydrive.mount entered failed state.
    Jun 23 22:32:00 home dhcpcd[236]: eth0: waiting for carrier
    Jun 23 22:32:00 home dhcpcd[236]: eth0: removing interface
    [email protected]:/media/mydrive/ /home/username/media/downloads/mydrive fuse IdentityFile=/home/username/.ssh/mykey,uid=1000,gid=1000,reconnect,_netdev,allow_other,transform_symlinks,user,idmap=user,BatchMode=yes 0 0
    ps: This issue might be related to a recent attempt I've had to enable? the Gnome NetworkManager service, I'm not sure if it's related but I've first noticed the issue the same day I tried to enable that service (which I've later disabled because I couldn't get my network connected).
    Last edited by Varemenos (2014-06-27 23:44:00)

    It just doesn't want to work...
    # systemctl status home-username-media-downloads-mydrive.mount
    ==>
    ● home-username-media-downloads-mydrive.mount - mydrive Sshfs mount
    Loaded: loaded (/etc/systemd/system/home-username-media-downloads-mydrive.mount; enabled)
    Active: failed (Result: exit-code) since Thu 2014-06-26 16:45:21 EEST; 31s ago
    Where: /home/username/media/downloads/mydrive
    What: [email protected]:/media/mydrive/
    Process: 281 ExecMount=/bin/mount [email protected]:/media/mydrive/ /home/username/media/downloads/mydrive -t fuse.sshfs -o IdentityFile=/home/username/.ssh/mykey,uid=1000,gid=1000,reconnect,_netdev,allow_other,transform_symlinks,user,idmap=user,BatchMode=yes (code=exited, status=1/FAILURE)
    Jun 26 16:45:21 home mount[281]: read: Connection reset by peer
    Jun 26 16:45:21 home systemd[1]: home-username-media-downloads-mydrive.mount mount process exited, code=exited status=1
    Jun 26 16:45:21 home systemd[1]: Failed to mount mydrive Sshfs mount.
    Jun 26 16:45:21 home systemd[1]: Unit home-username-media-downloads-mydrive.mount entered failed state.
    The file:
    [Unit]
    Description=mydrive Sshfs mount
    Requires=network-online.target
    After=[email protected]
    [Mount]
    What=[email protected]:/media/mydrive/
    Where=/home/username/media/downloads/mydrive
    Type=fuse.sshfs
    Options=IdentityFile=/home/username/.ssh/mykey,uid=1000,gid=1000,reconnect,_netdev,allow_other,transform_symlinks,user,idmap=user,BatchMode=yes
    [Service]
    Restart=on-failure
    RestartSec=10
    [Install]
    WantedBy=multi-user.target
    Note that running
    systemctl start home-username-media-downloads-mydrive.mount
    , works just fine...
    Last edited by Varemenos (2014-06-26 14:00:23)

  • How can I automatically mount a sparsebundle image prior to TimeMachine backup?

    I've been searching for a couple of days now a way to have Time Machine backup to a drive attached via USB.  The drive is a Western Digital 1TB hard drive formatted as NTFS and I'm using Tuxera to read/write from it.  I created a 300GB sparsebundle image with 256bit encryption via Disk Utility and was successfully able to mount the image and perform an initial backup via Time Machine.  All was well until I got an error stating that the backup image couldn't be loaded due to Error -1.  My guess it's because the image is dismounting and when Time Machine states it's looking for the backup image, it's unable to mount it.  I've added my password to the KeyChain Access section but am forced to manually mount the image prior to backing up or the backup fails.
    Most of the articles I've read deal with network backups but I only have one MacBook Pro Retina Display (Mid-2012) running Mountain Lion 10.8.2 x64 and would like to keep my Windows backups separate.  I'm not using a NAS and my setup is a BlackX enclosure holding the 1TB hard drive.  Is there something I can do to have Time Machine automatically mount the image prior to backing up?
    I wrote a small AppleScript to automate the mounting but I want the whole process automated.  I read iCal can help me but apparently it'll pop-up a window that I don't have to want to deal with.
    Also, backing up about 36MB takes around five minutes so I'm not thrilled about the speeds.  Hopefully there's also a solution for it.  I also tried Carbon Copy Cloner and (forgot the name of the other utility) but reading through the features, I just want to keep it simple with Time Machine.  I'm mostly concerned about corruption and loss of my data though I'm not sure how much better Time Machine is but am receptive to any suggestions.
    Thank you for your help.

    drag the dmg to the dock, right click, and "open at login?", that should achieve what you want

  • How do I get an encrypted dmg on a network share to automatically mount at login?

    I need to mount an encrypted dmg that is stored on an SMB share to automatically mount at login.  I've got the SMB share to mount at login as a "Login Item," but I can't get the encrypted dmg to mount.
    A related question:
    I've got a shell script that mounts my encrypted image, copies data using rsync, and then unmounts the encrypted image.  I tried automating this using a cronjob, but cronjobs are nut run as $USER.  Since the cronjob isn't run as $USER, the cronjob does not have access to the $USER's keychain and cannot authenticate to the encrypted dmg.  Any tips on getting either of these to work?

    I don't use SMB so I'm not sure whether this will work, but try it. Open a TextEdit window and type something like this:
    smb://user:password@server/path-to-file
    Make the obvious substitutions in the text, then select it and drag it to the Desktop. You should get a bookmark file. Double-click it to test. If it works, you can rename the file and put it anywhere you like. Add it to your login items.
    If the above doesn't work, try again with "cifs" in place of "smb".
    The "user:password@" part may not be necessary if the password is in your keychain.

  • Is there a way to prevent a Windows Logical Disk Manager volume from being automatically mounted?

    Lion is automatically mounting two LDM partitions from BootCamp, doesn't find a valid filesystem, and then asks to format or eject them, every time that the system boots.
    How do I go about preventing these disks from being automounted?
    They don't display UDID's, so I'm unsure if I can hide them using fstab, unless fstab supports the old disk-based specification that it used to.

    Although the little camera I was using doesn't capture 16 bit, I did run the jpgs briefly through ACR to try out the shadows/highlight feature since the photos were perfect candidates. My preference there is to convert to 16 bit ProPhoto so maybe--even though the files opened as jpgs. That might be the problem: maybe bit depth is the trigger for psd assignment. Still, I wish there was a way to disable it.

  • External hard Drive will not mount via firewire tpo my Powerbook G4

    I have a Powerbook G4 1.5, 2 Gb Ram and an 80 Gb Hard Drive. Well my problem is, I went and purchased a Western Digital External Hard Drive. The box states that this hard drive is compatible for both Windows and Mac. But for some reason I can't get the external hard drive to mount via the firewire. However it will mount by using the USB.
    So can someone please provide some troubleshooting tips on how I can get this external hard drive to mount?
    Thanks

    hi there,
    in your case, your drive is probably bad because the copy was interrupted. your hard drive may be finished, but more likely, just the file structure is damaged and/or you have bad sectors.
    you have a few options:
    *if you don't need the data back:*
    • see if the drive appears in disk utility and try to erase/reformat (make sure to zero out data to avoid bad sectors)
    • if it doesn't appear, try a pc. it won't recognize it, but it may allow you to reformat/initialize it. then, connect back into mac (which will recognize a pc formatted drive) and reformat as mac os x extended (journaled).
    *if you need the data back:*
    • try a program like data rescue II, file salvage, or boomerang data recovery first to recover the data
    • see if the drive appears in disk utility and try to repair disk
    • if that doesn't work, try disk warrior and/or drive genius
    • if you aren't successful, you may want to try a professional data recovery service (or me first, to ensure that you actually need someone as high tech as drive savers)
    • if you are successful and are able to recover the data, then erase the drive (zero out data) and then move the data back, to ensure you're working off a well formatted drive.
    fyi, if your computer freezes in the future, be sure to try appleoptionesc first and force quitting the problem application. if that doesn't work, try controloption+appleeject (shutdown) and/or optionappleeject (restart). if those doesn't work, in this situation, the next best move would probably have been turning off the power on the hard drive. if that doesn't unfreeze the system in a few minutes, then hold the power button.
    hope this helps,
    brian
    corewerkz/briancometa.com/

  • Automatically mount USB 3.0 WD External HDD with iMac 24-inch mid-2007

    I am using a 2TB Western Digital (WD) My Book Essential external Hard Disk Drive for my iMac 24-inch mid-2007 to use it as a Time Machine backup disk. This HDD only comes with a USB 3.0 connection. 
    Function-wise, it works with the iMac and Time machine uses it for backup without any issues.
    However, the following problem occurs at every restart: the HDD does not mount automatically. And Time Machine stops backuping. To make it work again, I have to either unplug/replug the power cable of the HDD or unplug/plug the USB cable of the HDD so it mounts again and can be used by Time Machine. When unmounted, I tried to see if the disk was at least visible in Disk Utility so I could mount it from there but it does not appear in Disk Utility until I physically unplug/plug it back again.
    For troubleshooting purposes, I have tried to use this HDD with my MacBook Pro Retina 2013 and I don't have the same problem as the HDD mounts itself automatically when I restart.
    So I assume the problem reside in the way the iMac mid-2007 handle USB 3.0 as it was probably manufactured before the USB 3.0 standard was developped.
    Would anyone know a possible workaround for this issue? I don't have too many hopes but one never knows...

    I am using Mavericks 10.9.1.
    The problem was also occuring when I was running Mountain Lion.
    It looks backward compatible to me except when it comes to automatically mount itself after a restart.

  • Stop automatic mounting of network volume

    I have a MacBook that is on a Windows network and connects to a 2003 server. Any time the MacBook is on it tries to auto mount a network volume on the Windows server about every minute or so using an account of an old user. This results in locking the user out of the network about every 5 minutes. I am looking for a way to shut this off.
    I have looked in the startup items and can’t find anything. I have also checked in the Login items under the user accounts with no success. Any ideas would be very helpful.

    To stop the automatic mounting of a network volume, try looking at Finder, Preferences, Shared, and uncheck the Connected Servers. I don't know if this solves your real problem of (deleted user) drive mapping, but at least it stops trying to mount the volume.

  • Filesystem from sdcard won't mount via fstab, will with rc.local

    Since receiving my laptop back from RMA, I've installed my SSD and set up Arch.  I wanted to put /var on a separate reiserfs partition on my 8GB sdcard to prevent extra write activity from logs and pacman, however it wouldn't mount.  I tried using both label and dev (haven't tried uuid yet) and it always failed, causing me to enter admin mode.
    I then set up a 1.5GB partition with reiserfs on the SSD for the time being, changing the pacman cache option to a directory on the sdcard in /media.  I set the command to mount in rc.local and it mounts fine there.  I can't get the other media partition to mount via fstab either.
    Is there another hook I need to add to mkinitcpio.conf and rebuild the init ram image in order for this to work?  Any ideas?  I'm going to try adding usb to the hooks and rebuilding for now.
    Here is my setup:
    fstab:
    devpts /dev/pts devpts defaults 0 0
    shm /dev/shm tmpfs nodev,nosuid 0 0
    LABEL=boot /boot ext2 defaults 0 1
    LABEL=home /home ext4 defaults,noatime,discard 0 1
    LABEL=root / ext4 defaults,noatime,discard 0 1
    LABEL=var /var reiserfs defaults,noatime 0 1
    #LABEL=sdcard /media/sdcard ext4 defaults,noatime 0 2
    none /tmp tmpfs nodev,nosuid,noatime,size=1000M,mode=1777 0 0
    rc.local
    mount /dev/disk/by-label/sdcard /media/sdcard
    mkinitcpio.conf hooks line:
    HOOKS="base udev autodetect pata scsi sata filesystems"
    EDIT:
    I tried adding usb to the HOOKS array between sata and filesystem, rebuilt the image, uncommented my sdcard entry in fstab, and rebooted.  It didn't fix it.
    I see someone made a hook in the AUR:
    http://aur.archlinux.org/packages.php?ID=31150
    Last edited by DarksideEE7 (2011-05-08 13:18:56)

    I'm a little confused, so maybe I'll learn something here.  It is my impression that /var is not, and need not be mounted while in using the initrd.  It will be mounted in init after the kernel has been loaded, / has been mounted/ and init started.  rc.local definitely is not executed until long after the initrd has been cast aside.
    Things to look at:
    Does the mount point /media/sdcard exist at the time rc.local runs?  I'd wager not.
    Look at the output of ls -l /dev/disk/by-label and recheck the disk labels.

  • Automatically mount an ftp drive on the finder at startup?

    Is there any way to automatically mount an ftp drive on the finder at startup?  I would like to use this to a centralized and controlled way for company staff to access and download files while outside the company.

    thanks for the suggestion.  Not sure what you mean by network volume?
    Most of the time I access the ftp using Transmit.  It will mount the disk to the finder, however only for the duration that the computer is running.  Likewise the ftp disk can be dragged to the login items, however will not open or connect following a restart.
    I have tried Automator, set up a small app in the startup items, and viola, it works like a charm.  Transmit opens automatically, mounts the ftp disk and then transmit shuts down.  Great.
    Now is there any way that this can be set up on a LION server, so that the ftp mounts, and then can be shared for access to clients on the company's local network?  Staff could then upload files that they would like to have available on mobile devices.

  • [solved] automatically mount crypted partitions

    Hey!
    I have an encrypted partition on my extern esata drive. I'd like it is automatically mount it on plugging in the drive.
    For that I have found an tutorial (unfortunately in German) about how to do it with udev:
    http://michael.stapelberg.de/Artikel/au … setup_udev
    But I'm using systemd, so this do not work this way.
    Can anybody explain me, how it will be done with systemd? I have to write a systemd unit file, haven't I?
    Thank you very much for some advices?
    Last edited by smohr (2012-07-27 12:44:23)

    I have solved it. Thank you Mr.Elendig!
    For running more than one command in your udev rules, it is necessary to execute them in a bash script and connect them with &&.

  • IPod mounts via Firewire, but not via USB

    My wife's iPod used to mount just fine via the USB connector on her PC.
    Now it doesn't mount at all via USB. I have tried two different cables.
    It DOES mount via my own Firewire cable.
    I have updated the iPod mini software to the latest, and the iTunes to the latest.
    Any ideas why USB no longer works?
    Thanks

    I wanted to get rid of this one since nobody answered. I think the 3G is simply broken. It works fine via firewire, and now I use it as a stationary music server -- the battery was too old for regular use. I bought a 5G.

  • Automatically Mount USB Drive on TC

    I have a USB drive attached to my TC and I use it for my itunes library. This works fine but when I use itunes on my macbook pro at home I must manually mount the drive. I would like to have the drive automatically mount whenever I am using my home network.
    Is there any way to do this?

    johnvic, welcome to the discussions!
    Open System Preferences, click on Accounts and then click on the Login Items tab.
    Click the + (plus) button at the bottom of the Login box and navigate to select your Time Capsule disk. Click Add.
    Time Capsule will open automatically the next time you restart your computer.

  • [solved] External drive automatically mounted as read-only

    Hi folks,
    I have a strange issue with an external drive automatically mounted as read-only whenever I plug it to my laptop :
    [sclarckone@archLaptop ~]$ mount
    /dev/sdb1 on /run/media/sclarckone/dd type ntfs (ro,nosuid,nodev,relatime,uid=1000,gid=100,fmask=0177,dmask=077,nls=utf8,errors=continue,mft_zone_multiplier=1,uhelper=udisks2)
    And I can't remount it as read-write :
    [sclarckone@archLaptop ~]$ sudo mount -o remount,rw /dev/sdb1
    mount: cannot remount /dev/sdb1 read-write, is write-protected
    But of course, I'm able to mount it as read-write on other operating systems.
    I have udisks and udisks2 installed on my system. I also belong to the storage group so I thought I could mount a filesystem as a normal user but I can't :
    [sclarckone@archLaptop ~]$ mount /dev/sdb1 dd/
    mount: only root can do that
    I don't know whether it is relevant to this problem, but I have systemd and polkit installed as well... Does anybody has an idea of where the problem could come from ?
    Thanks for your help !
    Last edited by sclarckone (2012-12-13 21:45:04)

    Check out following file :
    /usr/share/polkit-1/actions/org.freedesktop.udisks.policy
    Look for mount a device and It should have configuration like :
    <action id="org.freedesktop.udisks.filesystem-mount">
    <description>Mount a device</description>
    <description xml:lang="da">Montér en enhed</description>
    <message>Authentication is required to mount the device</message>
    <message xml:lang="da">Autorisering er påkrævet for at montere et fil system</message>
    <defaults>
    <allow_any>no</allow_any>
    <allow_inactive>no</allow_inactive>
    <allow_active>yes</allow_active>
    </defaults>
    </action>

  • LaCie External Harddrive suddenly won't mount via Firewire 400 or 800

    My LaCie External d2 Quadra suddenly won't mount via Firewire 400 or 800, but will mount via USB 2.0.
    I have:
    Tested the harddrive on another computer and it works fine via firewire.
    Shut down and re-boot. It had no effect.
    Updated all software.
    Note: My MBP will not boot if the Firewire 800 cable is connected.

    I've had a whole heap of strife with my two macally enclosures over FW. I've only got them working twice together, regardless of jumper settings on the harddrives. I can plug either in fine, but if I use both together, my mac shuts down and refuses to boot. One drive is bus powered, the other is powered via the mains
    I wish you luck

Maybe you are looking for

  • HP Windows 8 Recovery Failed (Used Recovery Discs)

    Hi. I not sure where to begin. System Info- HP Pavilion g6t-2200 Notebook Windows 8 (64bit) This is my sisters Computer. Her system was running slow so I was going to reinstall the OS using the Recovery Media I ordered for the system. Ive reinstalled

  • How to export a PDF from InDesign and keep the feature button ?

    I have an InDesign file with buttons and "Go to Page" features. So, the buttons are for navigate in the document. But when I exported my files in Interactive PDF, the "roll over" effect work, but buttons don't work.... How to save my PDF file for the

  • Agriculture Project - Advise and help needed

    Dear Gurus, I have done extensive preparation work for a project in Agriculture which is based on a cooperative model type from a SD module point of view (5 companies will share means of productions, labour, harvests), those 5 companies will rent the

  • Short dumps while using J3A9 & VK12

    We are implementing SAP ECC 6.0 and are experiencing short dumps while using transactions J3A9 and VK12.  They all point to program /AFS/SD_DISP_CONDITION_TABLE and related Includes.  I haven't found any information regarding this program on this sit

  • Can anyone help me with this question?

    hi experts Now I am writing a report and I have to get the number of how many pages is going to be displayed. How can I know this? I know there is a system variantsy-pagnocontains the current page number, but is there any variant that can tell me how