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

Implements RFD-0022 - OpenSSH-compatible Agent Forwarding #6525

Merged
merged 5 commits into from
May 7, 2021

Conversation

tcsc
Copy link
Contributor

@tcsc tcsc commented Apr 21, 2021

Prior to this change, tsh will only ever forward the internal key
agent managed by tsh to a remote machine.

This change allows a user to specify that tsh should forward either
the tsh-internal keystore, or the system key agent at $SSH_AUTH_SOCK.

This change also brings the -A command-line option into line with
OpenSSH.

For more info refer to RFD-0022.

See-Also: #1571

@tcsc tcsc force-pushed the trent/key-agent branch 2 times, most recently from 5c6105b to e9797fe Compare April 27, 2021 02:27
@tcsc tcsc marked this pull request as ready for review April 27, 2021 03:04
@russjones
Copy link
Contributor

@nklaassen @fspmarshall Can you review?

@nklaassen nklaassen self-requested a review April 27, 2021 21:58
@nklaassen
Copy link
Contributor

Does the command line option need to be updated, or is this coming in another PR? Seems like it is still a bool, and probably needs an update to the help string as well https://github.com/gravitational/teleport/blob/trent/key-agent/tool/tsh/tsh.go#L327

I'm not sure how difficult this could be, but would it be feasible to test that the correct key agent is actually forwarded when this option is set?

I missed the RFD review, but to me the options "yes" and "local" seem a bit unnecessarily confusing. Maybe something like "system" and "tsh", with "yes" as an alias to "system" could be more clear? Just spitballing here, not sure if this is reasonable

@tcsc
Copy link
Contributor Author

tcsc commented Apr 30, 2021

@nklaassen - the command line semantics are expected to change. From the RFD:

The effect of this change is that the tsh ssh option -A will automatically acquire
semantics in line with the OpenSSH client, while the backwards compatible behaviour
can be activated with something like:

$ tsh ssh -o "ForwardAgent local" [email protected]

We could potentially add something like -A means ForwardAgent yes and -A=local means ForwardAgent local, but given there is already a way to activate legacy behaviour I didn't think it worthwhile. Will look at the help string, though.

Re: the option value names, we're kinds stuck with "yes" and "no" as they are compatible with the OpenSSH ssh client options. Aliasing "yes" to "system" might be a useful affordance, but I'd be tempted to get feedback from the wild. I can take or leave the name "local", so if we want to change that I have no objections.

@nklaassen
Copy link
Contributor

@tcsc ahh I was just confused on that point, I thought that tsh ssh -A local was meant to work, realizing now that wouldn't line up with OpenSSH

As for the option value names, I'm just finding "yes" vs "local" unintuitive - both options could map to either one in my mind.

Copy link
Contributor

@nklaassen nklaassen left a comment

Choose a reason for hiding this comment

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

Code changes look good to me

tcsc added 3 commits May 4, 2021 20:53
Prior to this change, `tsh` will only ever forward the internal key
agent managed by `tsh` to a remote machine.

This change allows a user to specify that `tsh` should forward either
the `tsh`-internal keystore, or the system key agent at `$SSH_AUTH_SOCK`.

This change also brings the `-A` command-line option into line with
OpenSSH.

For more info refer to RFD-0022.

See-Also: #1571
@tcsc tcsc force-pushed the trent/key-agent branch from d513ec4 to 7888485 Compare May 4, 2021 10:54
Copy link
Contributor

@awly awly left a comment

Choose a reason for hiding this comment

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

Just to confirm: you tested this by logging into a remote server and running ssh-add -L?

lib/client/api.go Outdated Show resolved Hide resolved
tool/tsh/options.go Outdated Show resolved Hide resolved
@tcsc
Copy link
Contributor Author

tcsc commented May 5, 2021

Just to confirm: you tested this by logging into a remote server and running ssh-add -L?

$ ./build/tsh login --proxy 3.25.51.119 --user beaker --insecure
Enter password for Teleport user beaker:
WARNING: You are using insecure connection to SSH proxy https://3.25.51.119:3080
> Profile URL:        https://3.25.51.119:3080
  Logged in as:       beaker
  Cluster:            aws-standalone
  Roles:              admin
  Logins:             rowlf
  Kubernetes:         disabled
  Valid until:        2021-05-06 00:56:48 +1000 AEST [valid for 12h0m0s]
  Extensions:         permit-agent-forwarding, permit-port-forwarding, permit-pty

$ ./build/tsh ssh rowlf@auth-node
rowlf@ip-172-31-5-54:~$ ssh-add -l
Could not open a connection to your authentication agent.
rowlf@ip-172-31-5-54:~$ exit

$ ./build/tsh ssh -A rowlf@auth-node
rowlf@ip-172-31-5-54:~$ ssh-add -l
256 SHA256:dR1daFKmKLEDK055QNGbFi6zur2SSl+NOMnxzP4uBwQ [email protected] (ED25519)
2048 SHA256:5FPfhJMZH7x1yfzK9G3IZFqGkopy600C1AOR9sDH0A8 teleport:kermit (RSA-CERT)
2048 SHA256:5FPfhJMZH7x1yfzK9G3IZFqGkopy600C1AOR9sDH0A8 teleport:kermit (RSA)
2048 SHA256:AEML8fwmFdUazCzj+o1wEKBGIEaR33ei1zG4h5eZFU4 teleport:beaker (RSA-CERT)
2048 SHA256:AEML8fwmFdUazCzj+o1wEKBGIEaR33ei1zG4h5eZFU4 teleport:beaker (RSA)
rowlf@ip-172-31-5-54:~$ exit

$ ./build/tsh ssh -o "ForwardAgent local" rowlf@auth-node
rowlf@ip-172-31-5-54:~$ ssh-add -l
2048 SHA256:AEML8fwmFdUazCzj+o1wEKBGIEaR33ei1zG4h5eZFU4 teleport:beaker (RSA-CERT)
2048 SHA256:AEML8fwmFdUazCzj+o1wEKBGIEaR33ei1zG4h5eZFU4 teleport:beaker (RSA)
rowlf@ip-172-31-5-54:~$ exit

Copy link
Contributor

@russjones russjones left a comment

Choose a reason for hiding this comment

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

Bot.

@russjones russjones added the ux label May 5, 2021
Copy link
Contributor

@klizhentas klizhentas left a comment

Choose a reason for hiding this comment

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

Couple of nitpicks, but otherwise LGTM. You created a beautifully written RFD btw, especially the diagram, I enjoyed reading it.

func selectKeyAgent(tc *TeleportClient) agent.Agent {
switch tc.ForwardAgent {
case ForwardAgentYes:
log.Debugf("Selecting System Key Agent")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: (derived from https://github.com/golang/go/wiki/CodeReviewComments#error-strings). Let's make our log lines proper english sentences, so:

Selecting system key agent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Saw this after hitting Merge, will fix in new PR


default:
log.Errorf(
"Invalid agent forwarding mode %q. Defaulting to %q",
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Saw this after hitting Merge, will fix in new PR

@tcsc tcsc enabled auto-merge (squash) May 7, 2021 00:04
@tcsc tcsc merged commit 769b4b5 into master May 7, 2021
@tcsc tcsc deleted the trent/key-agent branch May 7, 2021 00:17
tcsc added a commit that referenced this pull request May 7, 2021
Prior to this change, `tsh` will only ever forward the internal key
agent managed by `tsh` to a remote machine.

This change allows a user to specify that `tsh` should forward either
the `tsh`-internal keystore, or the system key agent at `$SSH_AUTH_SOCK`.

This change also brings the `-A` command-line option into line with
OpenSSH.

For more info refer to RFD-0022.

See-Also: #1571
tcsc added a commit that referenced this pull request May 7, 2021
)

Prior to this change, `tsh` will only ever forward the internal key
agent managed by `tsh` to a remote machine.

This change allows a user to specify that `tsh` should forward either
the `tsh`-internal keystore, or the system key agent at `$SSH_AUTH_SOCK`.

This change also brings the `-A` command-line option into line with
OpenSSH.

For more info refer to RFD-0022.

See-Also: #1571
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants