mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-11-27 01:32:03 +00:00
194 lines
16 KiB
HTML
194 lines
16 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>CUCC Expedition Handbook: Windows expo laptop</title>
|
|
<link rel="stylesheet" type="text/css" href="../../css/main2.css" />
|
|
</head>
|
|
<body>
|
|
<h2 id="tophead">CUCC Expedition Handbook - Computers</h2>
|
|
|
|
<h1>Setting up a Windows expo laptop</h1>
|
|
|
|
<p>First read the generic instructions for all the software installations you will need:
|
|
<br>
|
|
<a href="basiclaptop.html">Setting up a basic Expo laptop</a>
|
|
<br>
|
|
<a href="yourlaptop.html">Setting up a machine for Expo data maintenance</a>
|
|
</p>
|
|
|
|
<p>It used to be quite simple: software equivalents existed for Windows for everything we needed. Since Spring 2018, we unfortunately have to use ssh keys. This has simply added an extra step for most things, but has made one thing (rsync) really quite hard to get working.
|
|
<p>What makes this all much more tiresome is that Microsoft are introducing some cool new ways of interacting with Linux systems but these are new and need some effort to get configured correctly. See the end of this page for more details.
|
|
<ul>
|
|
<li><a href="#well">Things that already work well with a Windows laptop</a><br />
|
|
- Editing the handbook webpages, typing up SVX files and transcribing the logbook, <br />
|
|
- Anything where the file-transfer to the expo server is via the git version control software
|
|
<li><a href="#problems">Things that cause problems</a><br />
|
|
- filenames and unintentional duplication because links are not understood by Windows,<br />
|
|
- sFTP or scp for more than a handful of files
|
|
<li><a href="#hard">Things that are really, really hard</a><br />
|
|
- using rsync <br />
|
|
- large-scale updating of several folders at once on expofiles without overwriting other people's work (which means using rsync)<br />
|
|
- well not "hard" exactly, but complicated with lot of steps that are easy to get wrong and with poor feedback as to whether you have done each step correctly.
|
|
<li><a href="#bold">The easier way to do it</a><br />
|
|
- using WSL: Windows System for Linux
|
|
<li><a href="yourlaptop.html#win">Possibly an even easier way to do it</a><br />
|
|
- using OpenSSH for Windows</ul>
|
|
|
|
<h3 id="well">Things that already work well</h3>
|
|
<p>Anything where the file upload and download is done via the verson control client software works really well.
|
|
|
|
<h4>Key management using PuTTy</h4>
|
|
<p>Most Windows software that we recommend "just works" if you have set up PuTTy and have done the <a href="keyexchange.html">key-pair setup</a> and are running a local ssh agent (pagent) automatically at boot up on your laptop.
|
|
<p>Some software, such as the commercial (but free) GitKraken, requires that you click a checkbox to say that you are "using local SSH agent" rather than specifying ssh private keys explicitly (File->Preferences->Authentication in GitKraken).
|
|
<p>Some software (such as Filezilla) defaults to using the local agent and it "just works".
|
|
<p>Brendan wrote a guide to using putty and git for expo on a Windows machine. It's worth reading and it has lots of screenshots: <a href="/expofiles/documents/idiots-guide-expo-git.pdf">Idiots guide to accessing expo git.pdf</a>.
|
|
<p>Read the online instructions abut using <a href="https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_overview">OpenSSH in Windows</a> as an alternative. (Then write them up and edit this handbook to be more useful.)
|
|
|
|
<h3 id="problems">Things that cause problems</h3>
|
|
<h4>Filenames</h4>
|
|
<p>Linux allows characters in filenames which Windows doesn't. There are also apparently normal filenames which Windows rejects (such as "<a href="https://answers.microsoft.com/en-us/windows/forum/windows_7-files/why-cant-i-create-a-folder-with-name/23c86662-4988-4c7d-9c2d-3e33d4413de3">CON</a>") for historical reasons. Linux filenames are case-senstitive and Windows filenames aren't: beware.
|
|
|
|
<h4>Symbolic links and sFTP</h4>
|
|
<p>Linux people like to use <em>links</em>. This is where there is really only one file, but it is referred to by different names. This is particularly useful when a file is moved, but you want people who have got the old location to still be able to find it. This happens quite a lot when updating handbooks.
|
|
<p>
|
|
The links you are most likely to come across are that what looks like
|
|
<span style="font-family:monospace; size=x-small; background-color: lightgray">/home/expo/expoweb</span> is really just a link to the folder <span style="font-family:monospace; size=x-small; background-color: lightgray">/home/expo/repositories/git/expoweb</span>, <br />
|
|
and that
|
|
<span style="font-family:monospace; size=x-small; background-color: lightgray">expoweb/essentials.gpx</span>
|
|
is a link to the file <span style="font-family:monospace; size=x-small; background-color: lightgray">/home/expo/expofiles/gpslogs/essentials/essentials2019.gpx</span>
|
|
<p>But that example is in the <span style="font-family:monospace; size=x-small; background-color: lightgray">:expoweb:</span> repository, so you won't be using sFTP to download it. Instead you will be using the version control software which handles it without problems. But we use it as an example of what to look out for when using sFTP.
|
|
|
|
<p>
|
|
<img src="fzlink.jpg" align="right">
|
|
There are two types of linux links: hard links and symbolic links. Symbolic links are much the same thing as Window's "Shortcuts" but there is no equivalent on Windows to Linux hard links. Fortunately we don't <em>seem</em> to have any hard links anywhere.
|
|
|
|
|
|
<p>What really makes things unpleasant is that sFTP software won't tell you when it comes across a link and will just do something stupid. Our recommended sFTP software - Filezilla - is guilty of this,as it pftp (PuTTy) working in eith sFTP or scp mode.. So what happens is that when you download a load of files onto your laptop using Filezilla it will simply turn every link it finds into a complete copy of the file. Then when you upload those files to the server, the copied file overwrites the link. So the server now has two files with the same content - which is a maintenance nightmare. This is painfully stupid because if it is a symbolic link there is no reason why Filezilla couldn't just create a Windows Shortcut which would do exactly the same thing. But it doesn't.
|
|
|
|
<p>So the ordinary user won't notice any problems, but the nerds behind the scenes start to cuss and shout and generally carry-on in an expletive-heavy manner.
|
|
|
|
<p>What is even more irritating is that Filezilla displays an link (<span style="font-family:monospace; size=x-small; background-color: lightgray">essentials.gpx</span> in the image) with a little arrow - it knows perfectly well that it is a symbolic link (although it does display it with a folder icon) - but it downloads it as a file copy.
|
|
|
|
<h4>Symbolic links: the solution for Windows</h4>
|
|
<ul>
|
|
<li>When using the git version control systems the download of a link works fine. But be careful not to edit the link file downloaded (it is just a text file holding the path of the file holding the actual contents) because then the version control client would upload it to the server and overwrite the link on the server with something that isn't a link. It also won't work as a Windows shortcut, but at least the default behaviour isn't actively dangerous.
|
|
<li>When using sFTP, manually check whether any files you are copying from the server are links - look at the symbol in Filezilla.
|
|
<li>Be careful not to copy any links using sFTP and instead recreate them manually on the Windows filesystem using right-click "Create shortcut".
|
|
<li>You will have to find out what to make the shortcut link to by logging in to the server (using a PuTTy ssh logon) and doing <span style="font-family:monospace; size=x-small; background-color: lightgray">"ls -l"</span> in the folder where the link is.
|
|
<li>But later, when re-uploading edited files from Windows to the server, Filezilla will see the Windows shortcut as a ".lnk" file which it will upload, but which will mean nothing to the linux server receiving it. So you would have to manually recreate the symbolic link by logging into the server using ssh and using the "ln -s" command. Yuk.
|
|
<br />
|
|
<li>Even if you use scp instead of sFTP, it does the same stupid thing when copying from a linux filesystem to a Windows filesystem. The PuTTy package includes <span style="font-family:monospace; size=x-small; background-color: lightgray">pscp.exe</span> but even if you force it to use the scp protocol like this:
|
|
<tt>
|
|
pscp -scp expo@expo.survex.com:expoweb/essentials.gpx .
|
|
</tt>
|
|
it downloads a <em>copy</em> of the contents of essentials.gpx and not a link.
|
|
<li>A possible fix in the future might be to keep all your expo files in a separate partition of your hard disc which is formatted with a linux filesystem (such as ext4) and run the <a href="https://www.ext2fsd.com/">ext2ntfs</a> driver to mount this fielsystem read-write from Windows. Probably not a good idea as the driver is a bit flaky in read-write mode and you could lose everything.
|
|
|
|
</ul>
|
|
|
|
<h3 id="hard">Things that are really quite involved</h3>
|
|
<p>The core problem is integrating the PuTTy key management software (pagent.exe) with a terminal window. We need a terminal window to run rsync as
|
|
none of the packaged software (Filezilla, PuTTy) includes an rsync client.
|
|
<p>[Well, strickly speaking we need a Windows rsync executable, and this does exist, and a command-line ssh, which the 'OpenSSH in Windows' system
|
|
provides. But we haven't properly explored this set of mechanisms yet.]
|
|
<p>The solution we have now for rsync is to use WSL and to create another key, distinct from the PuTTy one, and to upload that key to the expo
|
|
server. Because this is treating WSL as if it were a different machine requiring its own key quite separate from the Windows key. (This works the
|
|
same way in WSL1 and WSL2 - but see "Do you feel lucky, punk" below...)
|
|
<p>[We are not the only people to find this <a href="https://www.ubackup.com/windows-10/rsync-windows-10-1021.html">nasty and irritating</a>. Other
|
|
hacks are to use the obsolescent cygwin rsync or the rsync packaged within bash within more recent versions of 'Git for Windows' (which is built on <a href="https://www.msys2.org/docs/what-is-msys2/">MYSYS2</a>.
|
|
If you are already familiar with any of these, then use them and not WSL.]
|
|
<p>So on a machine with WSL enabled, create an ordinary cmd window and get into the WSL environment using the wsl command:<br />
|
|
<span style="font-family:monospace; size=x-small; background-color: lightgray">
|
|
D:\CUCC-Expo\expoweb\ <font color=red>wsl</font>
|
|
</span>
|
|
<br />
|
|
which puts you into the WSL environment with a new command prompt, e.g.<br />
|
|
<span style="font-family:monospace; size=x-small; background-color: lightgray">
|
|
<span style="color: green">
|
|
philip@Muscogee</span><span style="color: yellow">:/mnt/c/Users/Philip</span>$
|
|
</span>
|
|
<p>and now you can setup keys in the same way as you would on a Linux machine using ssh-keygen:
|
|
<pre>
|
|
<tt>$ <b>ssh-keygen -C "philip@muscogee-wsl"</b>
|
|
Generating public/private rsa key pair.
|
|
Enter file in which to save the key (/home/philip/.ssh/id_rsa): <b>id_rsa_wsl</b>
|
|
Enter passphrase (empty for no passphrase):
|
|
Enter same passphrase again:
|
|
Your identification has been saved in <em>id_rsa_wsl</em>.
|
|
Your public key has been saved in <em>id_rsa_wsl.pub</em>.
|
|
The key fingerprint is:
|
|
SHA256:ySs0YD5IG2ZD50+riUDHWosNq+WJdqpkDlINXh709r0 philip@muscogee-wsl
|
|
The key's randomart image is:
|
|
+---[RSA 2048]----+
|
|
| . o |
|
|
| ..+ . |
|
|
| oB+* + |
|
|
|.=O%.* + o |
|
|
|.+*o= = S . |
|
|
|.* o = . . . |
|
|
|=++.o . . E |
|
|
|B o . |
|
|
|oo |
|
|
+----[SHA256]-----+
|
|
$
|
|
</tt>
|
|
</pre>
|
|
The generated key is in the current directory and you need to move them to ~/.ssh/ as is standard on Linux (which is not at all the same place that PuTTy uses to keep keys on Windows).
|
|
<p>Now you have to complete the <a href="keyexchange.html">key-pair setup</a> with the new key "id_ras_wsl.pub". But you don't need anyone else's help this time as you can use PuTTy to ssh into the server and copy your key to the right place yourself.
|
|
<p>
|
|
Now finally you can use all the usual command line tools at yor wsl command line to communicate with the server with ssh, scp, rsync, such as:
|
|
<pre>
|
|
<tt>rsync -nazv --delete-after --prune-empty-dirs expo@expo.survex.com:expofiles/ expofiles</tt></pre>
|
|
<p>But this only works with WSL1 not WSL2 ! Under WSL1 it doesn't matter if your /expofiles/ is mounted on the Linux filesystem, typically under /home/expo/expofiles, or whether it it in the NTFS filesystem mount for Linux as, e.g. /mnt/d/expofiles. Under WSL2 /mnt/d/expofiles fails, either with a permissions problem or, if you try sudo rsync.. , with a ssh authentication failure (why? Given that we explicitly sate that we want to be user expo@ ?). Ghastly anyway.
|
|
<p>All of which is really a bit ridiculous if all you want to do is to use rsync on a Windows machine to sort out some photos.
|
|
|
|
|
|
<h3 id="bold">"Are you feeling lucky, punk"</h3>
|
|
<p>So here is the current wild frontier. Currently these are the ways to get a terminal window which you might expect to work:
|
|
<ul>
|
|
<li>cmd window - the old faithful going all the way back to MS-DOS. But no path to an rsync.exe executable as standard.
|
|
<li>PowerShell terminal window - nope, no rsync.
|
|
<li>bash window - installed by default when you install <A href="https://gitforwindows.org/">gitforwindows</a>. Unfortunately while this <a
|
|
href="https://en.wikipedia.org/wiki/MinGW">MINGW32</a> setup includes a command-line git executable it doesn't include rsync. (Well you have
|
|
to excavate it yourself, see <a href="https://prasaz.medium.com/add-rsync-to-windows-git-bash-f42736bae1b3">a 2020 script</a>, alternatively <a
|
|
href="https://blog.tiger-workshop.com/add-rsync-to-git-bash-for-windows/">a 2017 recipe</a> or <a
|
|
href="https://gist.github.com/radleta/0b337a2b14f761951cf2aab0578512b9">recent experiments</a>.
|
|
This technique seems too fragile for us to bother with, but you might be lucky.)
|
|
<li>cygwin - a cmd terminal where you have downloaded and installed <a href="https://www.cygwin.com/">Cygwin</a>. Yes, if you have selected the
|
|
rsync package you will be able to run the rysnc executable, but it won't have access to the cyptographic key so it can't connect to the expo server (but
|
|
you can make it work by using it with ssh from OpenSSH).
|
|
Please feel free to work out how to make this work. A more recent, graphical variant is <a
|
|
href="https://hackaday.com/2017/03/29/swan-better-linux-on-windows/">Swan</a>.
|
|
<li><img src="wsl.jpg" align="right" hspace="10"><a href="https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux">Windows Subsystem for Linux</a> aka
|
|
WSL available on all Windows10 machines since November 2019.
|
|
<ul>
|
|
<li>WSL <a href="https://docs.microsoft.com/en-us/windows/wsl/install">Install it like this</a>. This does what we need. This works using a key generated
|
|
by its own version of ssh-keygen if you follow the instructions above about putting it in the right place.
|
|
<li>WSL: <a href="https://hackaday.com/2019/12/23/linux-fu-wsl-tricks-blur-the-windows-linux-line/"> Converting Windows paths to Linux paths and
|
|
vice-versa</a>.
|
|
<li>In WSL you can choose whether to store the files in the WSL view of NTFS, e.g. /mnt/c/expo/ or in an ext4 filesystem e.g.
|
|
\\wsl$\Ubuntu-20.04\home\expo . Our experience is with WSL1 with the files on NFTS e.g. /mnt/d/expo/ .
|
|
<li>Not all machines are compatible with WSL1 though, see <a href="wsllaptop.html">WSL in more depth</a> and WSL2 differences.
|
|
|
|
|
|
Even if you have the hardware, you may have to enable it in
|
|
your BIOS and install the Windows Feature to do it. Instructions <a href="https://www.omgubuntu.co.uk/how-to-install-wsl2-on-windows-10">here</a>
|
|
and <a href="https://www.windowscentral.com/how-install-wsl2-windows-10">here</a>.
|
|
|
|
|
|
</ul>
|
|
<li>A full <a href="https://www.brianlinkletter.com/installing-debian-linux-in-a-virtualbox-virtual-machine/">virtual Linux machine</a> running
|
|
using a hypervisor such as <a href="https://www.virtualbox.org/">VirtualBox</a> which has its own virtual Linux filesystem. This setup has the
|
|
advantage that you don't have to partitition your hard drive but the disadvantage that you may not have easy access to the files from Windows (a feature
|
|
it shares with WSL2).
|
|
<li><a href="https://github.com/canonical/multipass">Canonical Multipass</a> - a VM alternative (Ubuntu only).
|
|
</ul>
|
|
|
|
|
|
<h3>Installing and Configuring the rest of the software you need on Windows</h3>
|
|
<p>Now return to <a href="yourlaptop.html">the data maintenance laptop</a> page to configure all the rest of the software you need.
|
|
|
|
<hr /></body>
|
|
</html>
|