Bash – cadaver automatic login (WebDav Client)

bashwebdav

I have been using cadaver recently, although is there a way to login automatically e.g. a one liner:

cadaver http://webdav.server.com user=xxxxxxxxx pass=xxxxxxxxxxx

I can't use davfs2, since my VPS won't mount WebDav, because it complians about FUSE.

Best Answer

You can use the .netrc file but be aware this is a security risk. It contains the password for the dav account with no encryption. Some of the precautions you need to use are:

  1. Don't use the password for this anywhere else.
  2. Set the .netrc file permissions 400 or 600 and owned by the user running cadaver. Use
  3. If possible have the cadaver program run as its own user that only runs the script.

Here is the info for netrc from the cadaver man page.

THE .netrc FILE
   The file ~/.netrc may be used to automatically login to a server
   requiring authentication. The  following  tokens  (separated  by
   spaces, tabs or newlines) may be used:

   machine host
          Identify a remote machine host which is compared with the
          hostname given on the command line or as an  argument  to
          the open command.  Any subsequent tokens up to the end of
          file or the next machine or default token are  associated
          with this entry.

   default
          This  is  equivalent to the machine token but matches any
          hostname. Only one default token may be used and it  must
          be after all machine tokens.

   login username
          Specifies  the  username  to  use  when logging in to the
          remote machine.

   password string
   passwd string
          Specifies the password to use  when  logging  in  to  the
          remote machine.

   Any other tokens (as described in ftp(1)) are ignored.

Good luck, Rik

Related Topic