The plist that others have mentioned (/System/Library/LaunchDaemons/com.apple.InternetSharing.plist
) never seems to change regardless of the state of Internet Sharing -- at least under Snow Leopard.
I think the answer lies somewhere in /usr/libexec/InternetSharing
and /etc/boopd.plist
.
First, try running:
sudo /usr/libexec/InternetSharing -d
You will probably see messages like the following:
InternetSharing[40307]: InternetSharing starting
/etc/bootpd.plist is empty/missing
InternetSharing[40307]: no primary service specified, exiting
It turns out that /etc/bootpd.plist
is created when Internet Sharing is started from the Sharing pref pane, and it is deleted when Internet Sharing is turned off.
If you are feeling adventurous, you could try manually creating the plist file. I enabled Internet Sharing with Ethernet shared to AirPort and copied the text of the resulting /etc/bootpd.plist
file to a pastebin here: http://pastebin.com/gQVzARfa
This plist doesn't contain all the necessary settings (e.g. SSID for the wireless shared connection), so I'm guessing it won't work on its own. I'm still looking for the other settings and will update this answer if I find them. (It's possible some are passed in as parameters to /usr/libexec/InternetSharing
, but I can't find any documentation on that.)
Once you have created the plist file, try running sudo /usr/libexec/InternetSharing -d
again. We may be able to work through this one error at a time. At this point it's really an academic exercise, as it would be far easier to reinstall your OS to fix your pref pane issue. ;]
If by some miracle it does start, I believe /usr/libexec/InternetSharing -q
will stop sharing.
Messing with your system files is always somewhat risky, so make sure you have a recent backup of your important files (I recommend Dropbox).
Bash has special provisions in its source code to source ~/.bashrc
when it's invoked by rshd
or sshd
. It's a compilation option, which given your experience seems not to be turned on under OSX.
If you're logging in with a key, you can (ab)use the command=
option in the ~/.ssh/authorized_keys
file.
A key with a command
option is good only for running the specified command; but the command in the authorized_keys
file runs with the environment variable SSH_ORIGINAL_COMMAND
set to the command the user specified (empty for interactive sessions). So you can use something like this in ~/.ssh/authorized_keys
(of course, it won't apply if you don't use this key to authenticate):
command=". ~/.profile;
if [ -n \"$SSH_ORIGINAL_COMMAND\" ]; then
eval \"$SSH_ORIGINAL_COMMAND\";
else exec \"$SHELL\"; fi" ssh-rsa …
Note that I put line breaks above for legibility, but this actually needs to be all on one line.
How can I set environment variables for a remote rsync process? may have other helpful suggestions.
Best Answer
You can enable SSH from the Terminal with:
(note that you need to run this as an admin, and it'll ask for your admin password, which won't echo as you type.)