I have a new computer on my desk at work. Today I felt the need to install CygWin to get mosh up and running.

I started by downloading the small bootstrap installer setup-x86_64.exe. I figured all dependencies would be selected automatically once I selected the package that I was interested in, namely mosh. Even though the installer asked me nicely if I wanted to install some more packages, I had to rerun the installer not once, but twice, as it became apparant that both Perl and OpenSSH were missing.

The lesson to be learned is to select mosh, Perl, and OpenSSH, all at the same time. More lessons would soon follow.

I have previously set the HOME environment variable to %USERPROFILE%\Documents, simply to ease working with GNU Emacs, Oracle VirtualBox, etc. CygWin magically translates this value to /cygdrive/c/Users/trond/Documents. To much surprise, OpenSSH does not use the HOME environment variable, but rather use a somewhat hardcoded default like /home/trond/.ssh.

Since I installed CygWin in the C:\cygwin64 directory, /home/trond/.ssh translates to C:\cygwin64\home\trond\.ssh. Neither C:\cygwin64\home\trond\.ssh nor C:\cygwin64\home\trond existed at the time, so naturally OpenSSH complained loudly like this:

Could not create directory '/home/trond/.ssh'.

and like this:

Failed to add the host to the list of known hosts (/home/trond/.ssh/known_hosts).

I also discovered that Windows Explorer doesn’t allow you to create directories with names beginning with a dot, e.g. .ssh. That’s completely strange to me, but I guess the people behind Microsoft Windows thinks differently than some of us.

Creating the directory C:\cygwin64\home\trond finally enabled OpenSSH to create its beloved /home/trond/.ssh and put some contents in /home/trond/.ssh/known_hosts.

After completing this ordeal, could I finally put mosh to good use.

BTW, these aliases could be handy:

alias FQDN='echo -en "\033]0;mosh: FQDN\007"; mosh -a FQDN -- screen -rx'
alias x='exit'

If you have no other customisation of bash, then simple store your (updated) aliases in ~/.bash_profile like this:

alias > ~/.bash_profile