9 ms·
Show HN: A WireGuard Powered Remote Shell
Time to announce Noisy Sockets Shell, the first in a series of WireGuard powered applications I'm working on. Noisy Sockets Shell is an SSH replacement that uses WireGuard for authentication and encryption, and WebSockets for communication.
CLI and browser client available.
- codetrotter 2y agoWhat does this bring over binding sshd to the Wireguard interface address? That’s what I do currently with some of my hosts.
- ghxst 2y agoIs there a small writeup available somewhere about this? I like the idea.
- OMGWTF 2y agoI guess you just need to configure `ListenAddress` in your `/etc/ssh/sshd_config` properly (see `man sshd_config`).
- inbetween 2y agoYou also need to change the boot behavior of sshd to wait for wireguard (tailscale in my case) to be available. I had to add a couple of lines to the ssh systemd unit.
- codetrotter 2y agoYep. And also pay attention during package and system upgrades on some systems. In certain cases it messes up this ordering, and you end up with sshd starting before Wireguard again and then sshd doesn’t find any interface with the specified address, which in turn makes it so that it won’t bind to that address. Making the machine unreachable until you manually fix it again.
- napkin 2y agoA less finnicky approach would be binding to 0.0.0.0, then configuring incoming firewall policy. By default deny, then allow SSH through wireguard network. Or by default allow then deny SSH through public network.
- codetrotter 2y agoI like that idea a lot. I may start doing that.
- semi 2y agoif you want to get fancy and/or over engineered you would use systemd templated units to setup sshd@.service and a ListenAddress in the config listening on %i. Then you could bring up sshd@(expectedip).service for each expected IP .. but that doesn't gain all that much tbh.if anything the only hesitation I'd have on listening to * and relying on firewall rules is if the service comes up before its configured. but exposing sshd isn't even that bad
- sureglymop 2y agoYeah I would do it with nftables so you don't have to change the sshd listen address.
- RealStickman_ 2y agoYou can create an override file for sshd to avoid issues due to package config changes. https://www.freedesktop.org/software/systemd/man/latest/systemctl.html#edit%20UNIT%E2%80%A6 https://www.freedesktop.org/software/systemd/man/latest/syst...
- codetrotter 2y agoI did something like that but somehow after an upgrade I still lost access to one of my systems that I had set up like that. This machine is physically in a different city from me so I rarely have the chance to go there. And lately I’ve even been in another country.
- eyegor 2y agoWhy don't you just add sshd restart as an interface PostUp step in the client's wireguard config file?
- deleted 2y ago[deleted]
- augusto-moura 2y agoI heard that ssh is kinda of an unnecessary step, since wireguard is already encrypted by default. Even legacy rsh should work fine in that setup. But I'm still not convinced, having double encryption is not a real performance problem in the real world. And I prefer it, just to be safe
- yencabulator 2y agoSSH can authenticate a user, wireguard (as typically deployed) only authenticates a computer. SSH can sometimes authenticate intent, like Yubikey touch. Using wireguard for authentication is a mistake. The category of mistake is usually referred to as ambient authority, often exploited via a confused deputy.
- jmole 2y agoI think you are misunderstanding the use of wireguard here - this is a userspace wireguard connection, so the process has the same permissions as the user executing it. In one sense, this is no different than adding a public key to ~/ssh/authorized_keys. If you control the key, you control the authentication.
- yencabulator 2y agoIn the case of the project linked, yes. I'm responding to the comment that said > I heard that ssh is kinda of an unnecessary step
- augusto-moura 2y agorsh would fill the same gap for authentication, (or even raw telnet), or anything that integrates with unix users. What makes SSH different is the encrypting part. The keys were only introduced to be used by the encryption algorithms. Users and multiple identities were a core detail of nixes much before SSH
- yencabulator 2y ago
- MuffinFlavored 2y agoWhy does the client have a listen port? nsh config init -c server.yaml -n server --listen-port=51820 --ip=172.21.248.1 nsh config init -c client.yaml -n client --listen-port=51821 --ip=172.21.248.2 Typically, servers have easiest to configure NAT/firewall/port forwarding and clients (to me) are basically thought of as "not going to get through their router/firewall configuration no matter what".
- dpeckett 2y agoBecause WireGuard is a P2P protocol and if you want the server could be behind a NAT (eg. reverse shell). Very useful for accessing your home machine without having to open up a port etc. In the near future noisysockets will get NAT traversal support (with a Nebula lighthouse type server) which will make this use-case a lot simpler.
- MuffinFlavored 2y agoI don't think this is accurate? The flow I've seen is "Wireguard server has its listening port open. Clients (with all ports closed) connect to the server on its open port." After that, all connections can still happen. Server -> client, client -> server. > NAT Traversal: The NAT entry created by the client's outgoing connection allows the server to send packets back to the client. > VPN Tunnel: The established VPN tunnel enables bidirectional communication, allowing the server to reach the client without the client needing an open port.
- CapeTheory 2y agoLooks like you created a bespoke license for your tool, which is your perogative but also means many people won't even consider using it.
- MuffinFlavored 2y agoWhy would people consider using it over "regular WireGuard setup with opensshd somewhere"?
- betaby 2y agoPerhaps to use it as a jump host. Oftentimes running ssh via ssh is not that good performance wise.
- deleted 2y ago[deleted]
- dartos 2y agoI was wondering the same thing, but another comment on this post pointed one out. It’s clunky to distribute and rotate ssh keys, but much easier to do that with WireGuard credentials.
- yjftsjthsd-h 2y agoI'm drawing a blank; why would it be easier to rotate wg keys than ssh keys? They're both asymmetric keys that fit in one line of text, which should be generated on the client and then have the public key uploaded to the server(s), and which can be dynamically loaded at runtime. If anything, I'd think ssh was marginally easier because it supports CAs out of the box and you can just have your auth system dynamically signing the user's certificate.
- deleted 2y ago[deleted]
- dpeckett 2y agoAnd that's totally fine :). It's worth noting that as a derivative of the FSL/BSL in four calendar years everything will be released back to the community under the MPL-2.0. The shell implementation is already under the MPL-2.0 and worth a look at for anyone who's interested https://github.com/noisysockets/shell https://github.com/noisysockets/shell
- fguerraz 2y ago[flagged]
- ta988 2y agowhy is that?
- hendersoon 2y agoWG itself doesn't support user authentication of any kind, it's just a tunnel. If you have the right key and send a properly signed packet WG will pass it. Encryption keys are not authentication in of themselves.
- adtac 2y ago> properly signed packet How would an adversary do this without the private key? Wireguard uses ChaCha20Poly1305, an AEAD scheme. The first A stands for Authenticated.
- arrakeenrevived 2y agoThis is pedantism, and is also just wrong. "if you have the right key" IS authentication. Encryption keys are used as a form as authentication all the time, it's one of the main use cases of public/private key encryption. I challenge you to explain how OpenSSH does non-password authentication without referring to encryption. Authentication just means proving who or what you are. Secret keys, whether they be passwords or encryption keys, are one of the primary ways to do this. Just because the key is also used for something else in addition to, or as part of, that process doesn't change it from being authentication.
- yjftsjthsd-h 2y agoWell, regular WG authenticates at the host level (roughly), not the user level, which can matter. I think this actually does auth at the user level, but there is some nuance there.
- 2y ago
- 0xbadcafebee 2y agoIf I can make a rough attempt at summarizing this: this is basically a PoC of a remote shell using the Noise Protocol Framework[1] with implementation Noisy Sockets[2] to effectively use UDP to tunnel a connection from one application to another directly and securely. If you squint at it, Noisy Sockets is basically like TCP+TLS, but UDP+SomeOtherCrypto. The library is a drop-in replacement for the Go 'net' library. All the protocols (including tcp/udp) are implemented in userspace. This has some really interesting use cases (like not having to use HTTPS to get a bidirectional secure communication channel... not being limited by firewalls... not requiring an OS to upgrade its tcp/ip stack...). Normally I'm a pessimist but I kinda like this thing (the library, not the remote shell). Just needs a less clunky way to discover and route to services, a simpler way to configure a connection to the remote host, and extensible authentication/authorization (public keys pose management problems and don't fit some use cases). That custom license may stop people from using the remote shell. Luckily the library is just MPL 2.0 [1] https://noiseprotocol.org/noise.html#introduction https://noiseprotocol.org/noise.html#introduction [2] https://github.com/noisysockets/noisysockets https://github.com/noisysockets/noisysockets
- deleted 2y ago[deleted]
- dpeckett 2y agoVery good summary, and thanks for bringing up the license distinction, the noisysockets core library will always be MPL-2.0 and open to the community. The fundamental thesis behind noisy sockets is, "What if your network endpoints were processes instead of machines?" And as you say bypassing the host networking stack actually brings a lot of benefits (eg. avoiding those VPN leak shenanigans), it's actually interesting when you squint enough it begins to even look vaguely something like QUIC (in that you have multiple encapsulated streams/channels/sockets going over UDP with their own congestion control). Peer discovery and NAT traversal are next on my list. I'm going to implement a kind of userspace lighthouse peer that will advertise peer endpoints to the network. I'm still trying to think about how I will deal with TURN/DERP. I suspect I'll tunnel WireGuard over WebSockets and just have each peer listen on UDP/TCP. Maybe one day that will allow even an in browser peer with WASM (which I'm sure someone will find an interesting use case for). Also on the list is fine grained authentication/authorization (interestingly netstack has an iptables implementation), some of it will be opensource and some of it will be source available (sorry for the SSO tax).
- louwrentius 2y agoCan you explain which problem this tool / these tools solve? I’m not sure I understand the purpose.
- haiku2077 2y agoA similar tool is Tailscale SSH. They replace SSH keys, which are clunky to distribute and invalidate, with the same authentication mechanisms you use for the rest of your digital security. A great use case in the enterprise is wrapping old but mission critical systems that don't support modern encryption or authn requirements with WireGuard. SSH is a demo for that use case- there's a lot of proprietary TCP data protocols out there in the legacy enterprise world!
- mrbluecoat 2y agoSimilarly, NetBird SSH: https://docs.netbird.io/how-to/cli#ssh https://docs.netbird.io/how-to/cli#ssh
- louwrentius 2y agoThanks for the explanation!
- dpeckett 2y agoOne of the things on my TODO radar is to implement a LD_PRELOAD'able Unix sockets implementation. Plus I need to get some additional language bindings done (eg. Python).
- sneak 2y ago[flagged]
- deleted 2y ago[deleted]
- dpeckett 2y agoThanks everyone for the wonderful Sunday afternoon surprise, I'd posted this originally on a Friday and I guess a lot of us were out watching the polar lights. This was a fun project to work on. Right now it doesn't support a multi-user daemon mode, kind of similar to mosh. But in the future because the server is able to cryptographically verify the source of connections, it's only a matter of time until I implement something akin to a per user `~/ssh/authorized_keys`. With noisysockets I'm effectively building out a suite of WireGuard powered "apps". Which are small, unprivileged, programs you can attach to a WireGuard network and will act as virtual peers.
- kzrdude 2y agoTo what extent does this replace mosh? https://mosh.org/ https://mosh.org/ It seems like it could do some of the same usecases.
- colordrops 2y agoeternal terminal is better than mosh. it renders properly and provides scrollback.
- dpeckett 2y agoMosh was a big inspiration but I took a more traditional PTY based approach rather than object orientated updates. One thing it does have in common with mosh, is excellent roaming support. And the other major selling point is that the remote shell protocol is browser compatible. No need for things like "Shell In A Box".
- deadbabe 2y agoHello, it’s my understanding that WireGuard isn’t very secure, but it is very fast. Is that correct?
- cwaffles 2y agoWireguard is written by Jason Donenfield, a renowned developer with deep crypto knowledge. You can search him up and see for yourself. https://www.zx2c4.com/ https://www.zx2c4.com/
- deadbabe 2y agoYes, I apologize to all who downvoted me, someone told me OpenVPN was still the more secure choice for a VPN.
- ComputerGuru 2y agoPlease don’t anthropomorphize ChatGPT.
- deleted 2y ago[deleted]
- dartos 2y agoNo.
- aborsy 2y agoWireguard is the most secure VPN protocol.
- deadbabe 2y agoA quick google search seems to indicate OpenVPN is more secure.
- yjftsjthsd-h 2y agoGoogle is not a source; what exactly are you seeing that suggests that? The only things I can find against wg are that 1. it hardcodes crypto options, so if ex. its cipher choices proved vulnerable then it would be harder to fix (vs openvpn allowing, more or less, plug and play of whatever cipher you want), and 2. openvpn has been around longer. But wg is much less code to audit, has been audited, is now widely deployed and used at scale, and hardcodes extremely safe cryptographic choices. So... again, what specific claims/sources say that openvpn is safer?
- jan6 2y ago[flagged]
- deleted 2y ago[deleted]
- dathinab 2y agoOne surprising tricky part of encrypting "live input" protocols (like typing send over a shell) is that just encrypting them is not enough. You can use timing of packages send to e.g. extract passwords. (hence why SSH clients normally take additional precautions)
- josephcsible 2y agoWould you consider dual-licensing this under a FOSS license like the AGPLv3? That's strong enough copyleft that I think you'll be safe from what you're trying to avoid with your current nonstandard license.
- dpeckett 2y agoThat's actually a really good suggestion, the main reason for using a time limited source available license was that I didn't want to impose a viral copyleft on everyone and lock up the code forever. The custom license is a pretty basic derivative of the FSL-1.1 with MPL-2.0 instead of Apache (for a weak copyleft), I think I might keep the custom license in place (I'll make the very minimal changes from the stock FSL-1.1 clear). But adding an AGPLv3 license for those with ambiguity concerns is totally okay with me (it's ultimately more restrictive than the source available license in a lot of ways). Thank you for the great suggestion.
- dpeckett 2y agoDone, the noisysockets CLI is now available under the AGPLv3 (and NSSL-1.0), pick the license of your choosing with no legal ambiguity. If it turns out the FSL-1.1, and by virtue of being a derivative the NSSL-1.0 is legally sound, after four years the code will be available under the MPL-2.0. But you don't have to trust me, the AGPLv3 starts immediately. I'll update the source headers in the following days. Thanks!
- efitz 2y agoPretty cool, but the license is pretty toxic to commercial adoption. I would suggest also licensing under MIT, BSD or Apache if you want this to ever achieve any widespread usage. Unfortunately you are competing against SSH which has a mature ecosystem so if you want widespread usage then you need to make it attractive legally as well as technologically.
- zx2c4 2y agoWhy fork/copy&paste wireguard-go source code instead of using wireguard-go's existing netstack package? Couldn't you help improve instead?