Skip to content

Commit

Permalink
Allow setting port via instance tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jesserockz authored and ekini committed Jul 4, 2020
1 parent 509717e commit 940e070
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ There are the following EC2 instance tags that change behaviour:
1. (Deprecated) If a bastion instance has tag "Global" with value "yes", "true" or "1", then aws-ssh will use it for all VPCs. If there are multiple bastion instances, it chooses the instance that has the most common match in name.
2. "x-aws-ssh-global" - same as the above
3. "x-aws-ssh-user" - sets the ssh username in the config.
3. "x-aws-ssh-port" - sets the ssh port in the config.

Any comments and especially pull requests are highly appreciated.

Expand Down
5 changes: 5 additions & 0 deletions lib/reconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type SSHEntry struct {
InstanceID,
Name,
ProxyJump,
Port,
User,
Profile string
}
Expand All @@ -35,6 +36,9 @@ func (e SSHEntry) ConfigFormat() string {
if e.ProxyJump != "" {
output = append(output, fmt.Sprintf(" ProxyJump %s", e.ProxyJump))
}
if e.Port != "" {
output = append(output, fmt.Sprintf(" Port %s", e.Port))
}
output = append(output, fmt.Sprintf(" Hostname %s", e.Address), "\n")

return strings.Join(output, "\n")
Expand Down Expand Up @@ -137,6 +141,7 @@ func Reconf(profiles []string, filename string) {
}
}
entry.User = getTagValue("x-aws-ssh-user", instance.Tags)
entry.Port = getTagValue("x-aws-ssh-port", instance.Tags)
sshEntries = append(sshEntries, entry)
}
}
Expand Down

0 comments on commit 940e070

Please sign in to comment.