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

feat: match patterns in ssh_aliases #665

Merged
merged 1 commit into from
Nov 4, 2024

Conversation

legobeat
Copy link
Contributor

@legobeat legobeat commented Nov 3, 2024

Describe what this PR does / why we need it

Some people may use "dynamic" remote hosts like github.com-foo, github.com-bar, etc. Having to additionally add each as an explicit ssh_aliases entry can become a chore.

Does this pull request fix one issue?

Describe how you did it

Interpret keys in ssh_alieses configuration as Lua patterns. This allows an alias like github\.com-.*.

Describe how to verify it

Special notes for reviews

Checklist

  • Passing tests and linting standards
  • Documentation updates in README.md and doc/octo.txt

@legobeat legobeat marked this pull request as ready for review November 3, 2024 05:02
@legobeat legobeat force-pushed the ssh-aliases-patterns branch from 65dd35a to 3cd3597 Compare November 3, 2024 05:04
@pwntester pwntester merged commit 8cb88a4 into pwntester:master Nov 4, 2024
2 checks passed
@btkramm
Copy link

btkramm commented Jan 6, 2025

This pull request created a bug when using ssh_aliases!

The issue is with the pattern in the gsub call. When you use "^" .. alias .. "$", Lua treats special characters in alias literally, but you need to escape them to match them literally in the pattern.

The following ssh_aliases configuration does not work:

    ssh_aliases = {
      ['github.com-personal'] = 'github.com',
      ['github.com-work'] = 'github.com',
    },

and the following, does:

    ssh_aliases = {
      ['github.com%-personal'] = 'github.com',
      ['github.com%-work'] = 'github.com',
    },

In my case, github.com-work contains a hyphen (-) which has special meaning in Lua pattern, and the gsub call is unable to replace the host.

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