Go Back   MacRumors Forums > Apple Systems and Services > Mac Basics and Help

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 12, 2009, 08:11 AM   #1
FongMan
macrumors regular
 
Join Date: Feb 2006
Change directory in terminal to network drive

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?
__________________
MacBook Pro Late 2008 - 2.53Ghz/4GB/320GB 7200rpm
FongMan is offline   0 Reply With Quote
Old Nov 12, 2009, 08:23 AM   #2
MikeDTyke
macrumors 6502a
 
Join Date: Sep 2005
Location: London
Quote:
Originally Posted by FongMan View Post
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?
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.
__________________
KISS is a principle i'd love to live by, if only life would allow.
MacPro 06 Quad 2.0GHz, 12GB, 60GB SSD, 3x250GB Stripe, 120GB SSD Win7 & 2.7TB Drobo.
MikeDTyke is offline   0 Reply With Quote
Old Nov 12, 2009, 08:25 AM   #3
MikeDTyke
macrumors 6502a
 
Join Date: Sep 2005
Location: London
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.
__________________
KISS is a principle i'd love to live by, if only life would allow.
MacPro 06 Quad 2.0GHz, 12GB, 60GB SSD, 3x250GB Stripe, 120GB SSD Win7 & 2.7TB Drobo.
MikeDTyke is offline   0 Reply With Quote
Old Nov 12, 2009, 08:25 AM   #4
angelwatt
Moderator emeritus
 
angelwatt's Avatar
 
Join Date: Aug 2005
Location: USA
If it's your machine then I would turn on remote management and then SSH into the machine and run the command.
angelwatt is offline   0 Reply With Quote
Old Nov 12, 2009, 09:08 AM   #5
FongMan
Thread Starter
macrumors regular
 
Join Date: Feb 2006
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.
__________________
MacBook Pro Late 2008 - 2.53Ghz/4GB/320GB 7200rpm
FongMan is offline   0 Reply With Quote
Old Nov 12, 2009, 09:09 AM   #6
FongMan
Thread Starter
macrumors regular
 
Join Date: Feb 2006
Quote:
Originally Posted by angelwatt View Post
If it's your machine then I would turn on remote management and then SSH into the machine and run the command.
It is my computer but I'm not in town and I'm trying to figure out how to enable it remotely.
__________________
MacBook Pro Late 2008 - 2.53Ghz/4GB/320GB 7200rpm
FongMan is offline   0 Reply With Quote
Old Nov 12, 2009, 09:22 AM   #7
FongMan
Thread Starter
macrumors regular
 
Join Date: Feb 2006
Can't I telnet into my computer or something and try a thing? (Don't even know how to Telnet) >.< Such a n00b
__________________
MacBook Pro Late 2008 - 2.53Ghz/4GB/320GB 7200rpm
FongMan is offline   0 Reply With Quote
Old Nov 12, 2009, 10:36 AM   #8
angelwatt
Moderator emeritus
 
angelwatt's Avatar
 
Join Date: Aug 2005
Location: USA
Quote:
Originally Posted by FongMan View Post
Can't I telnet into my computer or something and try a thing? (Don't even know how to Telnet) >.< Such a n00b
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.
angelwatt is offline   0 Reply With Quote
Old Nov 12, 2009, 11:58 AM   #9
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by FongMan View Post
It is my computer but I'm not in town and I'm trying to figure out how to enable it remotely.
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.
chown33 is offline   0 Reply With Quote
Old Nov 12, 2009, 12:09 PM   #10
FongMan
Thread Starter
macrumors regular
 
Join Date: Feb 2006
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.
__________________
MacBook Pro Late 2008 - 2.53Ghz/4GB/320GB 7200rpm

Last edited by FongMan; Nov 12, 2009 at 12:17 PM.
FongMan is offline   0 Reply With Quote
Old Nov 12, 2009, 01:20 PM   #11
BlueRevolution
macrumors 601
 
BlueRevolution's Avatar
 
Join Date: Jul 2004
Location: Montreal, QC
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.
__________________
PIRATE PARTY OF CANADA Information leadership for the 21st century
BlueRevolution is offline   0 Reply With Quote
Old Nov 12, 2009, 03:25 PM   #12
FongMan
Thread Starter
macrumors regular
 
Join Date: Feb 2006
Okiedokes, well thanks all for the responses
__________________
MacBook Pro Late 2008 - 2.53Ghz/4GB/320GB 7200rpm
FongMan is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Mac Basics and Help

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
How to change directory for dowlloading updates? Eugene El OS X Mavericks (10.9) 3 Feb 2, 2014 08:14 AM
iPhone: Which file and directory is it to change a slider? bobright Jailbreaks and iOS Hacks 3 Apr 14, 2013 02:56 AM
How to change dock icons (applications, downloads folder, network drive) Fish7 Mac Basics and Help 4 Jan 1, 2013 09:08 PM
Change location default home directory mattiasvdm OS X 10.8 Mountain Lion 2 Oct 11, 2012 10:08 AM
change user home directory name jtjones3 Mac OS X 10.7 Lion 0 Jul 29, 2012 09:02 PM

Forum Jump

All times are GMT -5. The time now is 05:13 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC