Don’t Be Sloppy
So, to preface this, a few weeks back I set up an SFTP server for myself and a couple friends. It was mostly as a learning experience for myself, setting it up with a proper chroot jail and everything, and also using two unfamiliar pieces of software for the web frontend side of things, Caddy as a webserver and Authelia as a more robust alternative to HTTP Basic Auth. It ended up turning out quite nicely and I still use both Caddy and Authelia for this site.
However, I very quickly ran into a problem: There’s not really very many good ways to access SFTP drives natively on Windows. With FTP or SMB there are options within the file explorer to mount shares as virtual drives, but no such option for SFTP exists natively. Now, a normal person would just set up an SMB share on the same server and have them share storage pools, buuuuut I was far, far too lazy to figure out how to make that play nicely with my permissions handling on the SFTP side. A more normal person would just use something like FileZilla, but where’s the fun in that? I did a bit of searching around for solutions to this problem and pretty quickly stumbled across sshfs-win, a fairly popular project on GitHub. Gave it a look, installed it, everything went breezy…
…except for the fact where the client was outright refusing to connect to the server. Fuck. That’s when I knew that it was gonna be a long night.
I spent pretty much the rest of my night troubleshooting this. Trying various different configurations, disabling the chroot jail, even using a completely bone-stock SFTP server, and nothing. I was at my wits end with this project, exhausted, 4 hours until I had to go to work, and about ready to give up for the night. That was, until I noticed a stray issue on the GitHub page that I hadn’t seen before. #450, “Does this work with key based authentication?” Now, if I had actually clicked on this issue I would’ve seen the answer to my problem right there, but my dumb self didn’t pay it much attention…for a few seconds, until I clicked away and realized “oh fuck, I use an ed25519 key. Is that fucking it up?”
So I looked. I checked the README, and sure enough, there it was:
The
sshfs.kprefix maps toHOST:~REMUSER/PATHand uses the ssh key in%USERPROFILE%/.ssh/id_rsa.
Finally, a solution to this problem. All it took was me aliasing my id_ed25519 pair as an id_rsa pair and it connected without a hitch. Now, even though I had solved the problem, I was still fuming over this. I went and bitched about it to anyone I could, and told myself I was going to fork the project and actually learn C just to make it follow the more traditional OpenSSH standard of matching the SSH key to a server’s fingerprint. And that is, still, absolutely the way it SHOULD be done, but there was one thing I missed in my fervor, something I didn’t discover until I was writing this blogpost, right underneath that last part of the README:
To specify a different specific key, define an alias of the HOST with the specific private ssh key you want to use in the ssh config.
…Well, shit. I guess this is what happens when you take the quick and easy path instead of being thorough, huh?