Using Screen for cleaning up remote SSH access

From StarOS Community Wiki
Jump to: navigation, search

Sometimes your access to SSH for StarOS management purposes is inadequate due to the platform you are working from. For example, on an Apple laptop, the Terminal application is unable to forward mouse actions to StarOS. The fix in that case is to use xterm instead of Terminal. But in other situations, the problems are more profound, such as in working from a smart-phone where the available keyboard fails to define some important keys.

Solutions to keyboard and key-mapping problems can be crafted using the Unix "screen" utility which is available on Linux, FreeBSD, MacOS, etc. The idea is to first ssh to a host where you have screen set up, and then ssh through screen from there to your StarOS system. Screen has wide-ranging powers, and we look only at a few possibilities here through a particular example setup. You can customize the details and usage to suit your situation.

My biggest problem using ConnectBot on my Android smart-phone which has no mouse is generating the ALT codes. So I decided that a prefix of __ (a pair of underscores) should act like ALT. Thus __i would generate ALT-i and open up the "interfaces" menu. The following .screenrc file accomplishes that:

 bindkey -t __a stuff "\033a"
 bindkey -t __b stuff "\033b"
 bindkey -t __z stuff "\033z"
 bindkey -t __1 stuff "\033OP"
 bindkey -t __2 stuff "\033OQ"
 bindkey -t __3 stuff "\033OR"
 bindkey -t __4 stuff "\033OS"

Roughly, the meaning is that __x is to be replaced by ESC x for any letter x, and that __1 is to be replaced by ESC O P, etc. These replacements function as the corresponding ALT and F-codes for StarOS.

So I log in to the Linux or FreeBSD or MacOS box using ssh and then issue the command "screen ssh" and during the ensuing session I can use __f as ALT-f, or __i as ALT-i, or __2 as F2, etc. To benefit my smart-phone, I set up an alias so that "ss ap" evaluates to "screen ssh".