Skip to content

Instantly share code, notes, and snippets.

@morganestes
Created December 11, 2019 22:50
Show Gist options
  • Select an option

  • Save morganestes/724e451fddc3c2ddfd3cc849534ba7a7 to your computer and use it in GitHub Desktop.

Select an option

Save morganestes/724e451fddc3c2ddfd3cc849534ba7a7 to your computer and use it in GitHub Desktop.
Configure zsh ssh-add plugin
# Configure ssh-agent plugin prior to loading it.
zstyle :omz:plugins:ssh-agent agent-forwarding on
# Get all the keys that are in the user's .ssh directory and add them to the ssh-agent.
SSH_IDENTITIES=($(find ${HOME}/.ssh -name '*.pub' -type f -exec sh -c 'echo $(basename "${0%\.pub}")' {} \;))
zstyle :omz:plugins:ssh-agent identities "${SSH_IDENTITIES[@]}"
# Make zsh know about hosts already accessed by SSH
zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment