Curious as to how I can enable the sshd to start on startup solely using terminal. The GUI is great and everything but it doesn't go well with my bash scripts.
How to enable SSH server on startup through Terminal
sshterminal
Related Question
- MacOS – How to create a new user in Lion from the Terminal
- Running terminal commands on startup/login
- How to connect Linux server with Applescript using iTerm or Terminal
- MacOS – How to get 256 colors on the default Terminal over SSH
- Terminal – How to Unfreeze When SSH Connection Dies
- How to open SSH socks proxy at startup
- MacOS SSH – How to Open the SSHD Service
- Terminal – How to Enable/Disable Adobe Host Port
Best Answer
The short answer on how to enable sshd from the terminal is doing this:
The long answer on how to execute daemons or scripts on startup is a bit longer. There are two ways (that I know of) to do this:
The first one is through Startup Items, which are executed at the final phase of bootup, these are deprecated and shouldn't be used unless you need compatibility with Mac OS X 10.3 or earlier. You can take a look at how to do it this way in here.
The second one is launchd, a replacement for init and rc (among others). This is the recommended way and it's a bit trickier than just putting a script on a folder like in Linux. There are several ways to launch daemons, the preferred way it to launch them on demand (so they will be ready to launch but you won't see them in a ps for example, unless you are using them). The explanation is a bit lengthly and the list of options is long, you can take a look at the documentation here. You can take a look in /Library/LaunchAgents for examples, if you have Chrome installed, there is a file in there for the Google Software Updater called com.google.keystone.agent.plist, that runs at load time, you can start there.