How to set up a reverse Telnet on Mac OS X

The simplest method:

  1. telnet (or rather ssh) to your Mac
  2. type your screen /dev/cu.USBserial command

Now, if you wan't to connect to your mac directly into the com port, or allow other to do that and nothing else, here is a way:

  1. Create a dedicated user on your mac. Let's call it "comport" and log in as this user.
  2. Create a connexion script for this user. Create a file named /Users/comport/log2com.sh and insert these lines into it:

    #!/bin/bash
    /usr/bin/screen -R /dev/cu.USBserial
    
  3. Allow the script to be executed by running this command in your terminal:

    chmod +x /Users/comport/log2com.sh
    
  4. Finally, set this script as the login shell of your user. For this, in System Preferences > Users and Groups , in the users list, right click on the user and select "Advanced Option". Then, in the "shell" field, type in /Users/comport/log2com.sh, and click OK.

That's it. You can now telnet (I'd rather recommend ssh!) to this login on your Mac to get directly into screen.

Note that to exit you need to do it the screen way (usually Ctrl+A, then :quit Return).

Tested this on OSX 10.10.5. Let me know if it worked for you.