lukesampson / pshazz

Give your powershell some pizazz.
The Unlicense
575 stars 40 forks source link

Make ssh plugin work with disabled native OpenSSH client and no admin rights. #118

Closed robewald closed 2 years ago

robewald commented 2 years ago

Make the ssh plugin work with an installed but disabled native OpenSSH client.

lukesampson commented 2 years ago

Looks cool but I don't have time to test. Does this break anything?!

robewald commented 2 years ago

Not intentionally. I have picked the defaults to maintain current behavior.

lukesampson commented 2 years ago

What if... could this functionality be moved to a separate plugin, say plugins/rogue-ssh.ps1 instead of mixed in with the default plugins/ssh.ps1? So people could explicitly opt in to this if they find themselves in this situation. We could have a separate wiki page about how it works (linked from the README). No need to change the default.json theme either that way.

I'm just trying to figure out how we can get this in there but minimise potential disruption. Looks like a very handy workaround for people that need it.

robewald commented 2 years ago

There would be quite a bit of code duplication in a separate plug-in. But I am not against it.

The change in default.json not strictly needed. I tested that the plugin behaves that same with and without the settings in default.json. People with a different theme should not notice anything. I struggled finding out where to configure the plugin, therefore I added it as an example.

I can revise the pull request.

chawyehsu commented 2 years ago

@robewald The ssh plugin has a complete code logic, including ssh-agent env reloading/refreshing, for Non Win32-OpenSSH already, see: https://github.com/lukesampson/pshazz/blob/d43b3d65f78c5132ffcbb36f2080e71f35e4cf80/plugins/ssh.ps1#L166-L196

I understand what you need is to try to bypass the installed native OpenSSH (because of admin rights issue) and use alternatives. You can just add a configuration option to ignore the Start-NativeSshAgent function here: https://github.com/lukesampson/pshazz/blob/d43b3d65f78c5132ffcbb36f2080e71f35e4cf80/plugins/ssh.ps1#L161-L164

I think https://github.com/lukesampson/pshazz/pull/118/files#diff-c1f7162b8bcda127dba6ea7929b5ac6281bb727bdc09e86d658740e1e13e4ca6R166 is enough.

And then it should be able to start external ssh-agent by the logic mentioned above.

P.S. the configuration option should not be added into the default.json theme and you can create an owned one to enable this configuration.

robewald commented 2 years ago

I created a new pull request. #119