Results 1 to 6 of 6
  1. #1
    LordMelkor is offline Senior Member Well Known
    Join Date
    Jun 2005
    Posts
    275

    Default bash scripting question

    Hi All (maybe Volv can help me here seeing how he's a linuxer)

    I'm using the Mac OS X Terminal from work, and I have to connect to our shared directory via ssh, I found a way to mount the thing using fuse (MacFUSE in my case). This is useful to me because I periodically have to move around large numbers of files to specific folders, and stuff like that so its a lot easier to click and drag rather than to type "mv <sourcepath> <destinationpath>" all over the place.

    Now its possible to use the ssh mounting program (sshfs) from the commandline, so I decided that I'd automate the process via a program that I have that can run scripts whenever I plug my laptop in at work (MarcoPolo).

    Now the problem is that using the sshfs program from the command-line requires me to type in the password for connecting to the ssh directory. However if I use MarcoPolo to run the script I never see the the Terminal, so I never see the password prompt, I cant enter any password, so the script fails.

    Is there anything that I can add to the script that will enter the password automatically, or popup a window to prompt me for the password (although that would be less desirable). The sshfs program itself does not have an option to allow password entry before execution.

    Thanks!

  2. #2
    tigerm is offline Senior Member Frequent Poster
    Join Date
    Mar 2006
    Posts
    116

    Default

    I'm not a Mac user yet (still debating the move), and I've never used sshfs, but I do use openssh on Linux. No guarantees... here goes....

    First you need a program that will prompt for a password, e.g. x11-ssh-askpass. This appears to be available via Fink, although it seems it's not a final package so you would have to compile it yourself. Or find something else that fills the ssh-askpass role (for all I know you already have something--search for "ssh-askpass" on your computer).

    Then in your environment (either your login settings/files or within the script itself), set the SSH_ASKPASS environment variable to that program. Whenever a password is required for ssh, that program will pop up a little window for you to type the password. From the ssh man page:

    SSH_ASKPASS

    If ssh needs a passphrase, it will read the passphrase from the
    current terminal if it was run from a terminal. If ssh does not
    have a terminal associated with it but DISPLAY and SSH_ASKPASS
    are set, it will execute the program specified by SSH_ASKPASS
    and open an X11 window to read the passphrase. This is particu-
    larly useful when calling ssh from a .xsession or related
    script. (Note that on some machines it may be necessary to
    redirect the input from /dev/null to make this work.)

  3. #3
    LordMelkor is offline Senior Member Well Known
    Join Date
    Jun 2005
    Posts
    275

    Default

    hm I messed around with ssh_askpass for a while but I couldnt figure it out -__-, and there are pretty much no tutorials for Macs regarding the matter. oh well.

  4. #4
    tigerm is offline Senior Member Frequent Poster
    Join Date
    Mar 2006
    Posts
    116

    Default

    You can try ssh-agent and ssh-add. ssh-agent stays in memory and holds your credentials for whenever an ssh process needs it (no more password prompts!). ssh-add actually adds your credentials to ssh-agent. I don't believe this will work with plain passwords so you'll have to generate proper keys if you haven't already.

    The trick is that you need to start ssh-agent sometime before any of those ssh processes so that they pick up the environment settings that tell them where to find ssh-agent. Interestingly, in the linux distro I use, the window manager startup script is configured to run ssh-agent out of the box. Then, also before you use ssh, you'll need to ssh-add (just once per login session). Once that's done, whenever you use ssh it won't bug you about passwords.

  5. #5
    LordMelkor is offline Senior Member Well Known
    Join Date
    Jun 2005
    Posts
    275

    Default

    kk thanks illl try that.

  6. #6
    Volvogga's Avatar
    Volvogga is offline Senior Member Always Around
    Join Date
    Sep 2005
    Location
    MI, USA
    Posts
    2,076

    Default

    http://www.linuxjournal.com/article/8904

    You might want to read that too... never fucked with SSH network shares. No idea how it's done. That page has some nice tips for automating and such though... might be able to apply it. Sorry, all I can find.
    Vol~

    thanks to Silverwmoon!

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
vBulletin Skin by: ForumThemes.com
Powered by vBulletin® Version 4.2.0
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
SEO by vBSEO 3.6.0 PL2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79