The short list of tasks for getting SSH running:
Generate a keypair on the developer computer:
ssh-keygen -t rsa
Copy the public key of the keypair to the target machine (it's in ~/.ssh/id_rsa.pub)
Install the public key into the root user's list of authorized keys:
cat id_rsa.pub >> ~/.ssh/authorized_keys
Test if you can connect to the target machine using the keys (instead of a password...hint: if SSH doesn't say Enter passphrase, you've done something wrong)
Enable SSH on the target computer by changing the line in the /etc/hostconfig file to read:
SSHSERVER=-YES-
If you are unfamiliar with SSH, you should read the following IBM DeveloperWorks article ( http://www-106.ibm.com/developerworks/linux/library/l-keyc.html)
If you're using Mac OS X, you'll want to add the SSHAgent Plugin to your LoginItems (thanks Kevin Van Vechten!) so you only have to unlock your keypair once per login session. You can add your keys to the agent using the ssh-add command from the terminal
Use the following shell script to move the KEXT from the developer machine to the target machine:
# BUILD_FOLDER where Project Builder sends the output of the build. If you do this script in PB, you can skip this step by adding a Copy Files Build Phase # TARGET_TGZ_NAME the name of the tar-gz file for moving the KEXT from the Developer's machine to the target machine # SSH_USERNAME the username on the target machine (most likely root for KEXT's) # TARGET_HOSTNAME the hostname of the target machine (same as in the ARP setup from Step 0) # SYMBOL_FILENAME the name of the symbol file # KEXT_FOLDER the name of the directory storing the KEXT # KEXT_NAME the name of the Mach-O KEXT in the Contents/MacOS folder of the KEXT_FOLDER echo "[ ---- Copying KEXT output ---- ]" cp -Rfp ${BUILD_FOLDER}/${KEXT_FOLDER}* /tmp echo "[ ---- Compressing build files ---- ]" tar -czf /tmp/${TARGET_TGZ_NAME} /tmp/${KEXT_FOLDER}* echo "[ ---- Using SCP to send the build files to the target machine ---- ]" scp /tmp/${TARGET_TGZ_NAME} ${SSH_USERNAME}@${TARGET_HOSTNAME}:/tmp/${TARGET_TGZ_NAME} echo "[ ---- Using SSH to extract the build files and erase the compressed archive from the target machine ---- ]" ssh ${SSH_USERNAME}@${TARGET_HOSTNAME} tar -xzf /tmp/${TARGET_TGZ_NAME} -C / ssh ${SSH_USERNAME}@${TARGET_HOSTNAME} rm /tmp/${TARGET_TGZ_NAME} echo "[ ---- Calling kmodload on the target KEXT ---- ]" ssh ${SSH_USERNAME}@${TARGET_HOSTNAME} kmodload -o /tmp/${SYMBOL_FILENAME} /tmp/${KEXT_FOLDER}/Contents/MacOS/${KEXT_NAME} echo "[ ---- Copying the symbols back to the host machine ---- ]" scp ${SSH_USERNAME}@${TARGET_HOSTNAME}:/tmp/${SYMBOL_FILENAME} /tmp/
At this point you will have the KEXT loaded on the target machine and the symbols in the /tmp folder on the Developer's machine, all ready for GDB. You can also remotely unload the KEXT if you want:
# You'll need the name of the module defined in an environment variable # # KEXT_MODULE_NAME the name of the module defined in the Info.plist echo "[ ---- Removing the KEXT from the kernel ---- ]" ssh ${SSH_USERNAME}@${TARGET_HOSTNAME} kextunload ${KEXT_MODULE_NAME}