Instead of exposing the modem to the internet. What you need to do is to sent all commands you want to execute thru ssh.
You can do:
ssh -t USER@SERVER 'sudo minicom'
the t option is required since minicom is a screen-based program.
Developing in Java
If you are doing a java development what I would do instead on caling "Runtime.getRuntime().exec("COMMAND")".
Have a class that understand when is running on the developer machine or the actual computer. That way you can call that class with the command that you want to execute. When the projects runs on the developer you can 'encapsulate' the execution with an ssh program like.
Runtime.getRuntime().exec(ssh USER@SERVER 'COMMAND')
Considerations about remotly executing commands without password
Do an ssh connection relaying on a public/private key authentication. That way you dont need to enter the password manually on each command sent.
Since you are using Ubuntu, if you need to run commands with the sudo modifier have the user you use to connect ssh in /etc/sudoers declared as so: USER ALL= NOPASSWD:ALL