View Single Post
  #24  
Old 07-01-2021, 10:37 PM
mdella's Avatar
mdella mdella is offline
Registered User
 
Join Date: Mar 2004
Location: Scotts Valley, CA
Posts: 44
MOSH and my new MacOS

So, I was finally convinced two years ago to abandon my PC and move to MacOS. I knew it was a unix based OS but didn't feel like I really needed that for my work especially since 95% of my work was on the other end of SecureCRT. But then I started using Vagrant and splitting into multiple "VMs" on my local box (Macbook Pro, 32GB memory, 8-core i9 (about to migrate to the M1 chipset), etc) and being able to revisit the MOSH issue came back for me.

Needless to say, I've been using other SSH client applications that supported MOSH while commuting (pre-pandemic) because of all the drop outs on either the bus or the train. but now I can "sort of" make the use of SecureCRT with mosh. Using the work from ~andromar back on 02-29-2016, I only added to the end of the Send string a ";exit" so that when I was done, it also dropped out of my MacOS shell. For those that use Mac's and don't know about MOSH, you can use "brew install mosh" if you have homebrew installed on your Mac.

Additionally I broke the username and host into environment variables so that I didn't have to edit the longer string (asked to get the Expect/Send window bigger. Hard to manipulate these on small windows). This also made it easier to copy/paste the entry and only change the shorter entries.

Code:
export USER=mdella
export HOST=jump.cstone.com
/usr/local/bin/mosh --family=all $USER@$HOST;exit
(if you use ssh on a different port, add --ssh="ssh -p 2022" or whatever port you use)
(the --server option in the prior example is redundant if you're using a current version of mosh)

Some things to note here... You cannot make use of your SSH_AGENT forwarding doing things this way as MOSH basically cuts you off from the ssh transport mechanism. You'll have to set up your agent on the MOSH-server side (risky if you don't put passwords on your keys). This leaves your private keys out there on your first server. Not necessarily a good idea.

Sad that there are a lot of things that you can't do without full integration, but this at least allows me to use the "CRT" part of secureCRT still. Working on other pieces to put in the connection to make it smarter (I guess I need to figure out the scripting language with SecureCRT for the Mac).

Marcos

P.S. I wanted to change the MOSH server timeouts from my end (since I'm defining how long I want the process to wait for me). Normally I wouldn't allow this to be set by an end user, but figured someone might want to know how...

1. Edited the /etc/ssh/sshd_config on the destination machine to include "AcceptEnv MOSH_SERVER_NETWORK_TMOUT MOSH_SERVER_SIGNAL_TMOUT"
2. Edited my personal ~/.ssh/config file to have the following "SendEnv MOSH_SERVER_NETWORK_TMOUT MOSH_SERVER_SIGNAL_TMOUT"
3. On my mac, my default shell is zsh so I edited my ~/.zshrc file with the following:
Code:
export MOSH_SERVER_NETWORK_TMOUT=604800
export MOSH_SERVER_SIGNAL_TMOUT=100
__________________
Marcos Della
Data Center Cloud Architect
Nutanix

PGP Fingerprint: BDC7 AFFD E94F FA09 C839 9153 F5FF E128 3094 2B9E
Key ID: 0x30942B9E

Last edited by mdella; 07-02-2021 at 12:09 AM.
Reply With Quote