Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #170118

Re: cron, sshfs and sudo

From Daniel Bareiro <daniel-listas@gmx.net>
Newsgroups linux.debian.user
Subject Re: cron, sshfs and sudo
Date 2016-07-14 15:50 +0200
Message-ID <rUPbA-1TY-1@gated-at.bofh.it> (permalink)
References <rKWxI-3yM-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 17/06/16 04:01, Wim Bertels wrote:

> Hallo,

Hello, Win.

> use case: use cron to mount a sshfs share (with automatic key auth)
> 
> on 1 installation this is working fine:
> script:
> "
> #!/bin/bash
> 
> sudo -u user1 sshfs user1@123.234.1.2:/var/user1/shared /mnt/shared
> 
> exit
> "
> 
> on the other it keeps failing because the passphrase needs to be entered
> to unlock the key, it doesn't fail however without sudo and a custom
> user1 crontab entry; but as cron is run by root, this should be able to
> do easier
> 
> suggestions?

One possibility I can think is to generate a public/private key pair for
the "user1" and copy the public key to 123.234.1.2.

Then install keychain (aptitude install keychain), adding the following
lines to the profile of user1:

keychain ~/.ssh/id_dsa
. ~/.keychain/$HOSTNAME-sh

Finally, in the mounting script, be sure to add the following line
before mounting itself:

source $HOME/.keychain/${HOSTNAME}-sh


I hope this will help.

Kind regards,
Daniel

Back to linux.debian.user | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

cron, sshfs and sudo Wim Bertels <wim.bertels@ucll.be> - 2016-06-17 09:40 +0200
  Re: cron, sshfs and sudo Dan Purgert <dan@djph.net> - 2016-06-17 12:40 +0200
    Re: cron, sshfs and sudo Wim Bertels <wim.bertels@ucll.be> - 2016-07-14 14:00 +0200
  Re: cron, sshfs and sudo Daniel Bareiro <daniel-listas@gmx.net> - 2016-07-14 15:50 +0200

csiph-web