Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve #21 get_remote_info via ssh itself #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tony-sol
Copy link

@tony-sol tony-sol commented Apr 24, 2024

Improve get_remote_info function by making it to fetch actual ssh configuration options (like host, port, user) via ssh -G and parse its output, instead of parsing ~/.ssh/config file.

This makes the plugin unbound from the .ssh/config file and more accurate in case of multiple Host some-wildcard* sections, e.g.:

Host prod-app
	Hostname 10.10.10.01
Host prod-db
	Hostname 10.10.10.10
Host prod-proxy
	Hostname 10.10.20.00
	Port 1337
Host prod-* !prod-proxy*
	ProxyJump 10.10.10.01
Host prod-*
	User provisioner
	Port 1134
	IdentityFile ...

So, on ssh prod-app correct values will be:

#U provisioner
#H prod-app
#{hostname_short} prod-app
#{pane_ssh_port} 1134

according to ssh -G prod-app | head -4

host prod-app
user provisioner
hostname 10.10.10.01
port 1134

And on ssh myself@prod-app -p 9999 correct values will be:

#U myself
#H prod-app
#{hostname_short} prod-app
#{pane_ssh_port} 9999

according to ssh -G myself@prod-app -p 9999 | head -4

host prod-app
user myself
hostname 10.10.10.01
port 9999

@tony-sol tony-sol changed the title Resolves #21 get_remote_info via ssh itself resolve #21 get_remote_info via ssh itself Apr 24, 2024
@tony-sol tony-sol force-pushed the master branch 4 times, most recently from a5802c5 to 4bd013e Compare April 28, 2024 19:42
Copy link
Owner

@soyuka soyuka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, need to test that and will report back, thanks!

@tony-sol
Copy link
Author

Great!

Sorry, but can't link this pr to issue #21

@sysradium
Copy link

I like this approach as well, because it works, for example, with ssh -v, unlike the original solution.

@tony-sol
Copy link
Author

@soyuka is everything good?

@sysradium
Copy link

Probably busy giving talks :) I have been using the fork so far and all is good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants