-
Notifications
You must be signed in to change notification settings - Fork 59
Move opkssh key files to a separate location #122
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
Move opkssh key files to a separate location #122
Conversation
I know, we are from the same organisation but would be nice. Not everyone is using ssh-agent and the package would be directly useable without setting up the agent. Nevertheless to potentially overwrite an ssh certificate and check is it used beforehand by opk seems unlikely not an optimal solution. We have the usecase to use multiple providers and that solution could address our needs massively and support this repository :). |
Want to talk about this at this months community meeting? OpenPubkey Community Meeting 2:00 PM (ET) 6:00pm (GMT) |
As mentioned in the community meeting this PR will be on hold until client configuration is implemented. |
Merged the client config. We don't automatically create the client config you have to run |
0bc7e18
to
ee5e774
Compare
Finally got around to refactor the PR to use the client config. The functionality changed slightly. I now use the The opk config.yml got extended to include I added this information to the readme. Users with an existing config and users that create the config after this PR will see no change to the default behavior. It requires manual changes to the config to take effect. |
I propose to use https://specifications.freedesktop.org/basedir-spec/latest/ as standard definition for the locations and as fallback $HOME/.config/opk/... for default configs and .ssh/opk for the ssh keys. |
I fixed the login integration test that failed. |
@net42-jkeil The client config is only used by login at the moment so it seems natural that login manage it. That said, I'm not sure exactly what you mean here. What would the SetConfig function do? What is the intent? |
With my PR the Alternatively I could extend the if check to prevent it from accessing the uninitialized |
When you say |
What I meant was a variable in code. This way I could remove my changes to the integration test, too. I for my part do not require a |
Sorry, I misunderstood you. The config variable on the login command struct should always be set regardless of it if a config file exists or not. It is set in But yeah |
@EthanHeilman let me know once you got to check the PR and if there is anything preventing a merge. |
I'll have more free time on Thursday, so I don't get a review done by Wednesday, I'll give it a review Thursday night. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your hard work on this
4c4a628
to
49bdbc2
Compare
The git history should be corrected. README, error logs, var blocks and inline declaration changes made as requested. |
That was a fast turn around! No worry about applying my suggestions. Suggestions typically break the linter because github doesn't apply lint suggests and my suggestions are intended to communicate an idea not be 100% correct code. |
@EthanHeilman I think I addressed all suggestions and notes, please review when you have the time |
@net42-jkeil Going to take this for a test drive today and give it a review. |
I tried this, but I couldn't login in because I already had a config.yml which didn't define the I added this to my config.yml
but I got the following error
|
@EthanHeilman I completely missed Windows here. I have no environment to test it, but using filepath build-ins should do the trick. |
@net42-jkeil Checked and it works on windows now when
or no key_management set 1. Testing with When I change this to
I get
After creating this directory it worked. This isn't a bug, but I think it is a better UX if we automatically create the directory for the user. When 2 . Testing with I ran into the issue that if not ssh config exists I get
It did create this file 2025/05/25 14:45:12 Error executing login command: error logging in: failed to write SSH keys to configured key dir ( 3 . Testing with Created
It creates a file
I changed this to the correct value
So I can't get it to work EDIT: I see what I messed up. I assumed if the keys were in
And it worked perfectly |
Thank you for your review! All of the
I implemented this so that the config directory
This is only a temporary copy of the users SSH config I create. It is modified to include opkssh's SSH config and renamed to Testing in a Windows 10 VM things seem to work for me. Please retest with other paths.
|
I'm going to delay merge this PR for a few days because I want to get a new release out. I want to keep the release small in case we run into any bugs. This is very valuable PR and I really want to get non-agent based key management right. |
I'm been giving this PR a lot of thought and I came to the realization that we are using the config file option This is my proposal: We get rid of
To determine if we should write to
What do you think about this? This seems closer to what you originally proposed with this PR, but I am have been overly excited about using the client config file which was a mistake on my part. |
I had a chat with my colleagues and they agree that everything related to SSH (config and keys) belong in the The I'm reworking this PR right now. I will force push a clean version build with the updated main branch as the base. |
Agreed, this is less likely to be confusing if it is in the .ssh direcotry |
add login subcommand '--configure' move keys and ssh config to .ssh/opkssh Signed-off-by: Jkeil <[email protected]>
37d80dc
to
7f5a517
Compare
Please let me know once you had the chance to review this. Thank you |
I don't have time this week, but I'm going to make a push to get this reviewed and merged next week. This is currently one PR ahead of this PR for merging |
Signed-off-by: Ethan Heilman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@net42-jkeil Thanks for all your hard work on this. Really appreciate it and sticking with the PR review. This was an usually long review process. The benefit this brings to project especially when a user has different IDPs for different servers. |
Thank you for being open to this change. Lets see if we find more opportunities for contributions while using it internally. |
This PR changes how the key files opkssh creates on the client are stored.
Addressed problems:
It prevents problems in case the predefined allowed identity files (
id_ecdsa
/id_ed25519
) are already in use. (#69)If a user has to log into multiple systems handled by different providers the user has to run
opkssh login
andssh
in that order for each system because repeated calls ofopkssh login
will override the PK of the previous provider.Changes:
~/.ssh/opkssh/
to reduce clutter and make cleaning up easier~/.ssh/opkssh/config
Notable:
Identities that do not follow the standard naming convention or are not placed in the default location
~/.ssh/
are usually ignored. To fix this theInclude ~/.ssh/opkssh/config
directive has to be added to the users ssh config.This is to prevent possible corruption when regularly modifying the users ssh config.
The README has been modified to reflect this change. Additionally the command
opkssh config
has been added which checks for correct configuration and instructs the user how to modify their config if needed.With the upcoming PR #96 most users will not encounter those problems, but on systems without the ssh-agent this remains a problem.