sshtunnel icon indicating copy to clipboard operation
sshtunnel copied to clipboard

Add support for ssh-agent

Open yuguorui opened this issue 1 year ago • 2 comments

Add support for ssh-agent, which can simplify the use of encrypted private keys. As you can load encrypted private keys to ssh-agent to facilitate the sshtunnel.

yuguorui avatar Dec 02 '23 14:12 yuguorui

Hi, thanks for the PR. I'm open to the change, but using environment variables is a distinct change from the fact that everything else is configured through a JSON configuration file. We should be consistent in specifying agent information in the configuration file as well.

dsnet avatar Dec 04 '23 22:12 dsnet

Hi~ I re-adjusted the code logic to respect the user's configuration in json. When the user does not configure it, the environment variables are read by default and the actual effective values are printed in the log.

2023/12/05 20:13:44 main.go:179: loaded config:
{
        "SshAgentSocket": "/run/user/1000/keyring/ssh",
        "KeyFiles": null,
        "KnownHostFiles": [
                "/home/yuguorui/.ssh/known_hosts"
        ],
        "KeepAlive": {
                "Interval": 30,
                "CountMax": 2
        },
        "Tunnels": [
                {
                        "Tunnel": "127.0.0.1:8899 -> 127.0.0.1:8899",
                        "Server": "[email protected]:22"
                }
        ],
        "BinarySHA256": "f9554279606e0177ea88ce836a373025dfb8e19b478b25c578a6199b10c71356"
}
2023/12/05 20:13:44 main.go:314: sshtunnel starting

yuguorui avatar Dec 05 '23 12:12 yuguorui