- Enabling SSH service from command line in MacOS can be done using with some brief commands without using the GUI (Sytem preferences).
To do that, open an Terminal window and run the following commands:
$ systemsetup -setremotelogin on $ sudo sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
To disable remote login (SSH):
$ systemsetup -setremotelogin off Do you really want to turn remote login off? If you do, you will lose this connection and can only turn it back on locally at the server (yes/no)? yes $ sudo sudo launchctl unload -w /System/Library/LaunchDaemons/ssh.plist
- Now, we will set the VNC password for a user. A bit of googling later, I’ve found this perl script
#!/usr/bin/perl # # vncpasswd.pl # # Encode a password to enable access using with Apple Remote # Desktop's VNC service. # # License: I'm placing this script into the Public Domain. Use as # you wish, however you wish. You can even claim it to be your # own if you need. # # Usage: perl vncpasswd.pl [password] # ---------------------------------------------------------------------------------- # [Macoy] original script taken from: # [Macoy]http://www.macgeekery.com/user/unixgeek # [Macoy] this script revised by macoy [http://macoy.wordpress.com] # [Macoy] for easier usage & execution, follow these steps : # [Macoy]$ perl vncpass_macoy.pl [vnc_password] > startvnc.sh # [Macoy]$ sh startvnc.sh #---------------------------------------------------------------------------------- # set plain text password to the first argument on the command # line. Note: VNC on Mac OS X only uses the first 8 characters. $plainTextPassword = $ARGV[0] || die "You must specify the password on the command line!"; $plainTextPassword =~ s/^(.{8}).*/$1/; # convert the password to an array @passwordArray = unpack "C*", $plainTextPassword; # XOR key @vncXorKey = unpack "C*", pack "H*", "1734516E8BA8C5E2FF1C39567390ADCA"; # print the kickstart command... # [Macoy] commented line is the original command from unixgeek but it # [Macoy] didn't work w/ my current xserve. thus the script modification. # print "sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -clientopts -setvnclegacyi -vnclegacy yes -setvncpw -vncpw "; # [Macoy] this is the actual working command in my case: print "sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -activate -access -on -clientopts -setvnclegacy -vnclegacy yes -setvncpw -restart -agent -vncpw "; # print the password foreach $byteValue (@vncXorKey) { printf("%02X",$byteValue ^ (shift @ passwordArray || 0)); }
But maybe you would like to run it by hand to keep control over what happen. Honestly, I always recommend this way.
First you need to create a valid MacOS-VNC password, like with :
$ perl -we 'BEGIN { @k = unpack "C*", pack "H*", "1734516E8BA8C5E2FF1C39567390ADCA"}; $_ = <>; chomp; s/^(.{8}).*/$1/; @p = unpack "C*", $_; foreach (@k) { printf "%02X", $_ ^ (shift @p || 0) }; print "\n"' | sudo tee /Library/Preferences/com.apple.VNCSettings.txt your_password 6E5B241CD4D8A491FF1C39567390ADCA
Where your_password is the word you want to set as password.
$ sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -users <username> -privs -all -restart -agent -menu $/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -clientopts -setvnclegacy -vnclegacy yes -setvncpw -vncpw 6E5B241CD4D8A491FF1C39567390ADCA
This password is stored in the next file:
$ sudo cat /Library/Preferences/com.apple.VNCSettings.txt
To verify if our password is correct, run the next command:
$ sudo cat /Library/Preferences/com.apple.VNCSettings.txt | perl -wne 'BEGIN { @k = unpack "C*", pack "H*", "1734516E8BA8C5E2FF1C39567390ADCA"}; chomp; @p = unpack "C*", pack "H*", $_; foreach (@k) { printf "%c", $_ ^ (shift @p || 0) }; print "\n"' your_password
you will see converted to “human characters” the password set previously.
- Install pkgs from caommand line is also possible with:
$ installer -pkg "/Volumes/AppleJack-1.4.3/AppleJack Distribution.mpkg" -target /
- To create an iso file with the contents of an entire folder:
$ hdiutil makehybrid -o cosas.iso iso/
- Ejecting a disk can be done also. Check first with df -h wich device you want to eject and run..
$ disktool -e disk1
- To re-create your Extensions file, load or unload an specific “driver” (note the quotes) …
$ kextcache -v 1 -t -m /System/Library/Caches/com.apple.kext.caches/Startup/Extensions.mkext /System/Library/Extensions/ $ kextload /System/Library/Extensions/ApplePS2Controller.kext $ kextunload /Extra/Extensions/VoodooPS2Controler.kext
Or tu recreate the Extensions.mkext file in an external disk, userful if you’ve got a disk with a MacOS running there and you need to update your “MacOS drivers” (again, note the quotes about drivers)….
$ kextcache -a i386 -a x86_64 -l -mkext2 /Volumes/Snow6.3/System/Library/Caches/com.apple.kext.caches/Startup/Extensions.mkext -volume-root /Volumes/Snow6.3 /Volumes/Snow6.3/System/Library/Extensions>/pre>