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

ssh: remove persistent socket; use macOS Keychain #1394

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

slarew
Copy link
Contributor

@slarew slarew commented Jul 22, 2017

Proposed Changes

  • Remove persistent SSH auth socket.
  • Make ps|grep more robust and POSIX compliant.
  • On macOS, use -A switch to "add identities to the agent using any
    passphrase stored in the user's keychain."

@belak
Copy link
Collaborator

belak commented Aug 14, 2017

Looks like there's a conflict now. Would you mind fixing that?

@slarew
Copy link
Contributor Author

slarew commented Aug 14, 2017

I think I fixed the conflict.

Copy link
Collaborator

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

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

Seems both useful and straightforward to me, but I'd like another pair of eyes on it before merging.

@belak
Copy link
Collaborator

belak commented Aug 29, 2017

Does this still work on linux and does it connect to the same agent between different shell sessions? I'm not very familiar with this, unfortunately.

@slarew
Copy link
Contributor Author

slarew commented Aug 29, 2017 via email

@jeffwidman
Copy link
Collaborator

@indrajitr / @johnpneumann if either of you get a chance, can you take a look? I am in the same boat as @belak, that it looks good but I'm not very familiar with this and there's a number of changes in here.

Alternatively, the consequences of this breaking probably aren't the end of the world as it's unlikely to introduce a security risk, just a breakage risk so we'd hear about it immediately and fix it, so personally I'm fine with merging. Will give the other folks a day or two to weigh in though...

@johnpneumann
Copy link
Collaborator

I'll take a look tonight

@johnpneumann johnpneumann self-assigned this Aug 30, 2017
@crivotz
Copy link

crivotz commented Aug 31, 2017

I tested the modification on Debian v9.1 - zsh 5.3.1 and found no problems (with and without ssh-askpass)

Copy link
Collaborator

@johnpneumann johnpneumann left a comment

Choose a reason for hiding this comment

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

Try to find an elegant way of ensuring that users who define their ssh keys, within their .zpreztorc and that they can use the keychain as well. I was able to do it by checking the output of ssh-add -l again, but it's not DRY.

# Load identities.
if ssh-add -l 2>&1 | grep -q 'The agent has no identities'; then
zstyle -a ':prezto:module:ssh:load' identities '_ssh_identities'
# Check for Linux system and ssh-askpass presence
if [[ "$OSTYPE" == linux* ]] && [[ ! -a /usr/lib/ssh/x11-ssh-askpass ]]; then
ssh-add "${_ssh_identities:+$_ssh_dir/${^_ssh_identities[@]}}" 2> /dev/null
elif [[ "$OSTYPE" == darwin* ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

The problem I have with this is what if the user doesn't put their keys into the keychain and simply define them within the identities? What happens is that the identities that are defined are ignored entirely, so they're now being forced to put their keys into their keychain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe I have addressed your concern with 8430fb8.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@johnpneumann Could you review my changes in 8430fb8 to see if that fixes your concerns?

* Remove persistent SSH auth socket.
* Make ps|grep more robust and POSIX compliant.
* On macOS, use `-A` switch to "add identities to the agent using any
passphrase stored in the user's keychain."
If the user defines identities in `:prezto:module:ssh:load`, always try
to load them, even on macOS.  On macOS, also try to load Keychain
managed identities. (Assume if a user adds an identity to Keychain then
the use would want those identities automatically loaded.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants