Skip to content

Issues with Mapkey Function #414

@krishmoodbidri

Description

@krishmoodbidri

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

  1. The function reads the entire userAuthorizedKeysFile.
  2. It iterates through each key in the file using ssh.ParseAuthorizedKey.
  3. For each key, it compares it with the provided pub parameter.
  4. If a match is found, it returns the contents of userKeyFile.
  5. If no match is found after checking all keys, it returns an error.

Proposed Change

  1. Mapkey function shouldn’t be looking through authorized_keys file
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions