Skip to content

How to use sshfs under windows to mount a filesystem via a BastionHost/JumpHost

Today, I had the "joy" to work on a linux machine and edit a lot of files. The problem is, I had to use a Windows 10 as host OS.
Furthermore, the remote machine was available only via a bastion host/jump host. So it took me some time to make this possible.

I was not able to make sshfs-win working. WinSCP is a fallback option but this would result in edit a file -> save a file -> upload a file. I wanted to avoid the step upload a file.

What comes after this line is a snapshot of my created howto. I hope it will save you some time. It took me a lot to figure it out.

Given is, that you need to mount a filesystem via sshfs.

Following up, I will provide a guide how to do this by using a Windows 10 machine.

Bonus task, we are using a jumphost.

Steps

1.) Ensure you are running wsl2

  • wsl1 does not have a working fuse
  • Open a powershell and run wsl --list --verbose
  • If the VERSION says something bigger 1, you are fine
  • Else
    • Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    • Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
    • Download wsl_update_x64.msi from https://aka.ms/wsl2kernel
    • Install the msi
    • wsl --set-version <string: Distro like Debian> 2
    • Wait
    • wsl --list --verbose should output something like 2 in column VERSION

2.) Ensure you've sshfs installed

  • Open the shell to your wsl linux
  • test -f /usr/bin/sshfs && echo "sshfs already installed" || sudo apt install sshfs -y

3.) Configure your ssh

  • Open the shell to your wsl linux
  • test -d ~/.ssh || mkdir ~/.ssh;
  • Add content like the following in your ~/.ssh/config file
  • sudo bash -c "echo '#enable option' >> /etc/fuse.conf"
  • sudo bash -c "echo 'user_allow_other' >> /etc/fuse.conf"

Example content of the ssh config file

HOST my.main.host-username
  HostName my.main.host
  ProxyJump my.bastion.host-username
  User username
  #optional but recommended
  IdentityFile ~/.ssh/my_private_key

HOST my.bastion.host-username
  HostName my.bastion.host
  User username
  #optional but recommended
  IdentityFile ~/.ssh/my_private_key

4.) Mount and umount the filesystem

  • You can add the following lines to your alias
  • Assumed is, that the path ~/network/host.main.my exists
  • ssh my.main.host-username
  • id -a
  • exit
  • Not down the number for uid and gid
    • Example:
    • For the output uid=1337(artodeto) gid=4711(bazzline) groups=...
    • uid is 1337
    • gid is 4711
  • mount: sshfs -o ProxyJump=my.bastion.host-username,allow_other,uid=<int: number>,gid=<int: number> my.main.host-username:/my/path ~/network/host.main.my

Microsoft Sticky Notes Alternative Windows 10

After upgrading many clients to Windows 10, we ran into multiple issues with Microsofts Sticky Notes. Notes are "lost", Sticky Notes stopped working or has been removed by the system or what ever.

Simply Sticky Notes is our decided alternative.

Benefits are:

  • multiple language support
  • lightweight
  • contains backup mechanism
  • notes are stored in a sqlite database
  • you can move the storage path wherever you want

Create and manage a shadow copy snapshot for windows with powershell

Following my essence about the topic of creating a shadow copy snapshot.

#bo:create shadow copy
$shadowSourceVolume = ($env:SystemDrive + "\")
$shadowDestinationLinkPath = ($env:SystemDrive + "\shadowed_test")

#@see: https://docs.microsoft.com/en-us/previous-versions/windows/desktop/vsswmi/create-method-in-class-win32-shadowcopy#examples
$shadowCopyClass=[WMICLASS]"root\cimv2:win32_shadowcopy";

#create a shadow copy object
$shadowCopyObject = $shadowCopyClass.create($shadowSourceVolume, "ClientAccessible")
#fetch shadow object fron that
$shadowObject = Get-WmiObject Win32_ShadowCopy | Where-Object { $_.ID -eq $shadowCopyObject.ShadowID }
#fetch 
$shadowLinkPath = $shadowObject.DeviceObject + "\"
#eo:create shadow copy

#bo:create link
cmd /c mklink /d $shadowDestinationLinkPath $shadowLinkPath
#eo:create link

#bo: remove shadow link
cmd /c rmdir /S /Q $shadowDestinationLinkPath
#eo: remove shadow link

#bo: delete shadow copy
$shadowObject.Delete();
#Remove-CimInstance -InputObject $shadowObject
#eo: delete shadow copy

#bo: FTL
#list all available shadow copies
#Get-WmiObject Win32_Shadowcopy
#eo: FTL

Most important learned knowledge for me is that I only can create a snapshot of a whole volume.

Manage your windows installed software with chocolatey and backup your collection by using this little manager

While working more and more with windows, I wanted the freedom of having a centralized packagemanager under the hood to ease up "keeping software up to date" or manage installed software in general.

Right now, I ended up using chocolatey.

After using it and building up my "finest selection" of installed software, I wanted to backup this collection.

I found the needed powershell commands pretty fast. Since I am a lazy person, I wanted to even ease up this by just having two scripts doing all the "heavy work" for backing up and restore this software collection.

After 30 minutes of work, I was able to release version one of my chocolatey manager.

This is a simple wrapper to backup and restore packages maintained by chocolatey.

The "restore.sh" will install chocolatey if not installed. The "backup.sh" will create a local file containing the currently installed packages.

Hope I can put you too more into the lazy area with this.

Cheers, artodeto