Skip to content

Apple keychain support #5

@rktprof

Description

@rktprof

Is your feature request related to a problem? Please describe.

On macOS you can use ssh-add --apple-use-keychain (described here) to use credentials from the keychain instead of it asking for passwords, so it would be nice if that was an option.

Describe the solution you'd like

The simplest solution to make it an option would be to add something like this

zstyle ':zim:ssh' use-keychain true

Describe alternatives you've considered

I did some local modifications and came up with this that seems to work

Modified ssh/init.zsh

# Load identities
ssh-add -l &>/dev/null
if (( ? == 1 )); then
  PARAMS=""
  local enable_apple_keychain
  zstyle -s ':zim:ssh' use-keychain enable_apple_keychain || enable_apple_keychain=false

  if [[ $(uname) == 'Darwin' && ${enable_apple_keychain} == true ]]; then
    PARAMS='--apple-use-keychain'
  fi

  local -a zssh_ids
  zstyle -a ':zim:ssh' ids 'zssh_ids'
  if (( ${#zssh_ids} )); then
    ssh-add ${PARAMS} ${HOME}/.ssh/${^zssh_ids} 2>/dev/null
  else
    ssh-add ${PARAMS} 2>/dev/null
  fi
fi

There is probably a nicer way of doing it and I haven't tested it on linux, but it does what it's supposed to on macOS

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions