clj-commons / clj-ssh

SSH commands via jsch
234 stars 66 forks source link

ssh local port forwarding #67

Closed AndreaCrotti closed 1 year ago

AndreaCrotti commented 1 year ago

I'm just trying to convert this:

"ssh -L 3306:remote-mysql-host:3306 bastion"

to the equivalent ssh-clj code, so I was trying something like this:

(def agent (ssh/ssh-agent {}))

(def session (ssh/session agent
                          "bastion-host"
                          {:user "bastion-user"
                           :private-key-path "key-path"
                           :strict-host-key-checking :no}))

(ssh/forward-local-port session
                        3306
                        3306
                        "remote-mysql-host")

but even though I see no errors anywhere (and the port 3306 is open checking with nmap), I can't connect to the remote MySQL, while it works perfectly well with the ssh -L command. Any idea what I'm doing wrong or how to get more debugging information?

AndreaCrotti commented 1 year ago

Actually, I managed in the end, it was just me being silly. It might still be useful maybe in the README to include the equivalent ssh command to use.