3 ms·
When I was coding https://stackoverflow.com/a/77210784/308851 https://stackoverflow.com/a/77210784/308851 well, I had no idea how to open an SSH connection usin
by chx 2y ago
When I was coding https://stackoverflow.com/a/77210784/308851 https://stackoverflow.com/a/77210784/308851 well, I had no idea how to open an SSH connection using go, I barely knew basic Go so I asked ChatGPT. The meat of the SSH connecting code is still pretty much ChatGPT written (bad chx!) but it contained a couple defers like defer session.Close() which I needed to understand and remove before it became usable as a utility function. I did search for ssh.PublicKeysCallback(agent.NewClient(sshAgent).Signers) to see whether others use it and I found they do and their code was very similar so I decided to trust ChatGPT code even if I only understood it enough to understand but not enough to write similar code. It's just an SSH connection, the risk is quite low, the expected result of bogus code is just not working, I wouldn't expect subtle errors here. The rest of the logic is hand written, though.
- namaria 2y ago> It's just an SSH connection, the risk is quite low Yeah just a secure shell what ever could go wrong with code you don't understand? Probably nothing much right?
- chx 2y agowell, it's client. What could go wrong? I mean, it might not connect, right? I did understand it to some degree.
- OutOfHere 2y agoI would make sure the SSH client doesn't connect to a man-in-the-middle!
- chx 2y agoWell, that's fairly self evident. It's not like we are auditing thousands of lines of code: ssh.Dial("tcp", serverName, config) the tricky part , really , is the syntax for ssh config but again that's easy to understand even if it's very hard to write.