Change directory in terminal to network drive

Discussion in 'Mac Basics and Help' started by FongMan, Nov 12, 2009.

  1. macrumors regular

    FongMan

    Joined:
    Feb 4, 2006
    #1
    Hi Guys,

    I need to run a terminal command on my computer at home but it doesn't have screen sharing or remote management enabled. I do however have file sharing enabled and able to browse the drive freely. I want to run a sudo command on that drive but don't know how to run it from where I am. Anybody have any thoughts?
     
  2. macrumors 6502a

    Joined:
    Sep 7, 2005
    Location:
    London
    #2
    Unless you can use remote desktop or ssh on to your machine, you cannot run anything.

    You could in theory do this, if you prepare in advance.

    create a cron entry of the sort.

    0,15,30,45 * * * * sudo /Users/yourname/scriptname.sh

    Then add a sudo alias that doesn't need a password to run. ie.

    yourname ALL = NOPASSWD: /Users/yourname/scriptname.sh
    WARNING! This is very dangerous, if you mess up the script or someone malicious got access to your fileshare and put that script there with the contents...
    rm -fr /

    You can say goodbye to your machine.
     
  3. macrumors 6502a

    Joined:
    Sep 7, 2005
    Location:
    London
    #3
    Note you need to replace yourname with whatever your username is and should remove the script file or rename it once it has run.

    That cron will run every 15 mins, you might want to adjust it to something more or less often. Also if you ever checked the users mbox file, ie. not your regular email, you'd find a ton of script not found messages.

    I can't be sure, but you may not be allowed to have sudo in a cron entry. If that's the case, have a regular script in cron with the contents.
    sudo /Users/yourname/someOtherScript.sh
    Then change the sudoer privilege above to refer to someOtherScript.sh.

    Regards

    M. :D
     
  4. Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    If it's your machine then I would turn on remote management and then SSH into the machine and run the command.
     
  5. thread starter macrumors regular

    FongMan

    Joined:
    Feb 4, 2006
    #5
    Cron huh, never heard of that. Well I have my public IP and everything set ports forwarded. Ok...so that sounds complicated and risky without any guarantees. So is there a way for me to enable Remote Management without actually being by the computer? Changing a plist file or something. I did some research but again the method I found is through Terminal with another Sudo command.
     
  6. thread starter macrumors regular

    FongMan

    Joined:
    Feb 4, 2006
    #6
    It is my computer but I'm not in town and I'm trying to figure out how to enable it remotely.
     
  7. thread starter macrumors regular

    FongMan

    Joined:
    Feb 4, 2006
    #7
    Can't I telnet into my computer or something and try a thing? (Don't even know how to Telnet) >.< Such a n00b
     
  8. Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #8
    Telnet is just a command, like ssh. You'd need a port to telnet in on that's open already. Same difficulty as SSH. You're essentially needing to hack into your own machine, which means you need to find a security vulnerability in your setup. So if you find something that lets you in, it likely lets other people in and should be closed. I'm not sure of how to make use of the file sharing to get something to execute with sudo privileges.
     
  9. macrumors 603

    Joined:
    Aug 9, 2009
    #9
    If your computer hasn't already been configured for remote access, you can't enable remote access from a remote location. That would be a huge security hole. Think about it.
     
  10. thread starter macrumors regular

    FongMan

    Joined:
    Feb 4, 2006
    #10
    Yes it would be a security hole, but at the same time if you do have it configured it is still pretty hard to get in without the actual password. I guess I was just hoping that I would be able to connect to the computer, open a sharing preferences or remote management file and just adjust a setting. Or if I find a way to run a sudo command remotely then I would be able to do it.
     
  11. macrumors 603

    BlueRevolution

    Joined:
    Jul 26, 2004
    Location:
    Montreal, QC
    #11
    You can't execute a file remotely with file sharing. Unfortunately, you'll just have to enable remote login next time you have physical access to the computer. Then you can ssh in and sudo to your heart's content.
     
  12. thread starter macrumors regular

    FongMan

    Joined:
    Feb 4, 2006
    #12
    Okiedokes, well thanks all for the responses :eek:
     

Share This Page