-
-
Notifications
You must be signed in to change notification settings - Fork 151
Description
Description
The Mapkey function in the Workingdir struct (tg123/sshpiper/plugin/internal/workingdir/workingdir.go) is misaligned with the intended configuration for SSH authentication. The current implementation reads the entire userAuthorizedKeysFile and iterates through each key using ssh.ParseAuthorizedKey, comparing each key with the provided pub parameter. This approach is redundant and inefficient, given that the configuration structure only allows specifying a single private key for upstream SSH authentication, which is hardcoded to id_rsa.
Current Behavior
- The function reads the entire userAuthorizedKeysFile.
- It iterates through each key in the file using ssh.ParseAuthorizedKey.
- For each key, it compares it with the provided pub parameter.
- If a match is found, it returns the contents of userKeyFile.
- If no match is found after checking all keys, it returns an error.
Proposed Change
- Mapkey function shouldn’t be looking through authorized_keys file
- It should just use the defined key to authenticate to the upstream.
We have demonstrated this with our code change. We can set the key to id_ecdsa and just return that from mapkey and we get the desired behavior of using ecdsa for the upstream auth.
Overall we'd like to know the intended purpose of this function and even the necessity of it.