Commit graph

33 commits

Author SHA1 Message Date
Nuno Goncalves
a206271460
ssh-agent: improvements ()
* ssh-agent: lock this script with a mkdir style mutex

This script is a kind of singleton pattern and is not reentrant.
If several shells are oppened in a fast sequence, then several
independent ssh-agents would be created, which is not acceptable.
A mutex is required.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>

* ssh-agent: only start agent if .ssh dir exists

To use the same profile system-wide, it might happen
that the .ssh directory does not exist
(typically $HOME/.ssh/). This would trigger a error.

Creating the directory would be a option, but it
usually will not make sense to do so because it means
the user doesn't have ssh keys or config.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>

* ssh-agent: adds lazy option to disable key loading on start

Option is documented on updated README.md

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>

* ssh-agent: simplify agent-forwarding checking

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>

Co-authored-by: Robby Russell <robby@planetargon.com>
2021-06-11 19:03:25 -07:00
Marc Cornellà
02d07f3e3d
fix: use $USERNAME guaranteed to always be defined in zsh
Fixes 
2021-03-25 12:08:00 +01:00
Will Boyce
0e232d4853
feat(ssh-agent): add ssh-add-args setting ()
* ssh-agent: add `:omz:plugins:ssh-agent ssh_add_args` option

* Clean up and document extra setting

* Document valid ssh-add arguments

Co-authored-by: Marc Cornellà <hello@mcornella.com>
2021-03-15 22:51:33 +01:00
Marc Cornellà
101ea87232 ssh-agent: check if ssh-add -l was successful 2019-09-08 16:07:06 +02:00
Jannik
0f0448fa6c ssh-agent: consolidate uppercase message () 2019-05-07 21:21:55 +02:00
Marc Cornellà
c494869632
ssh-agent: check for loaded id filenames first ()
This change makes the plugin check if an identity is loaded by looking
first at the key filename reported by `ssh-add -l`. This fixes the use
case where ssh-keygen is not able to output the fingerprint of a key,
such as the one reported on .

Now, for an identity to be passed onto ssh-add, it has to fail the
match for a loaded identity, both filename and signature.
2019-01-21 20:31:30 +01:00
Marc Cornellà
9d1dd24e35
ssh-agent: add default keys if no zstyle identities were set () 2019-01-19 18:00:04 +01:00
Andreas
9329efd252 ssh-agent: autoload identities in one go ()
With this PR the ssh-agent plugin loads all identities which are not yet
loaded in a single call to ssh-add. If a passphrase is shared between
loaded identities it only needs to be entered once.

Fixes 
2019-01-14 16:42:14 +01:00
François Scala
2a60385659 ssh-agent: use key signatures to check loaded ids ()
Use fingerprint of ssh key instead of file name to control if the key is already loaded.

Also check for .ssh folder presence ()
2019-01-14 16:38:45 +01:00
Marc Cornellà
fabee55948
ssh-agent: autoload identities not already loaded ()
With this PR the ssh-agent plugin checks the `ssh-add -l` output for the
identities added, and adds all those specified by the user that haven't been
added yet.

We also decouple the logic of starting ssh-agent from the logic of adding
identities, meaning that even if ssh-agent has been started by some other means
(like launchd) we can still ssh-add the user's identities.

Fixes 
Fixes 
2019-01-09 21:19:52 +01:00
Janosch Schwalm
19b925e741 use https everywhere ()
* use https everywhere

* use https links on the files that are left

Also, removed some broken links and updated redirections.
2018-08-07 20:42:01 +02:00
Michael Stucki
302270174d Use existing ssh-agent when invoking a sudo shell ()
When invoking a shell as root using ```sudo -s```, the ssh-agent plugin
starts a new agent although it already exists.

The problem boils down to a check if ssh-agent is running using
```ps x```. If that is extended to ```ps ax``` for root, then the
existing ssh-agent will still work.
2018-07-01 18:20:34 +02:00
Marc Cornellà
ebda8af870
Clarify ssh-agent settings position 2018-05-28 17:09:53 +02:00
Marc Cornellà
5bd9500bf4 ssh-agent: check ssh-agent process w/ ps again
The alternative is using tools that aren't available everywhere.
The latest report is that cygwin/msys2 doesn't have pgrep.

Fixes .
2016-09-17 13:01:10 +02:00
Marc Cornellà
973a4e646c ssh-agent: fix non-standard process check w/ pgrep
Confirmed to work on MacOS, OpenBSD, Solaris and busybox.
2016-09-05 08:31:20 +02:00
Marc Cornellà
53c3567cc3 Force ssh-agent output to use bourne-style syntax
On systems where the shell cannot be changed because of a strict
security policy, ssh-agent will use the syntax of whatever the
default $SHELL is.
For instance, if the default shell is tcsh, ssh-agent will use the
c-shell style (setenv).

This change forces ssh-agent to use bourne-style syntax since that
has to be later interpreted by zsh. Consequently, the environment
file will contain `export' statements from now on (instead of
`setenv').
2016-09-03 20:49:55 +02:00
Marc Cornellà
142ad842d7 Simplify PID check of current ssh-agent 2016-09-03 20:49:55 +02:00
Marc Cornellà
cb0833ac13 Clean up formatting of ssh-agent plugin 2016-09-03 20:49:55 +02:00
Marc Cornellà
b60acddefe Extract comments into README for ssh-agent plugin 2016-09-03 20:49:55 +02:00
Marc Cornellà
81e73e3d18 Delete useless /usr/bin/env in ssh-agent 2016-09-03 20:49:55 +02:00
Maximilian Güntner
0c60f421cb ssh-agent: Use /usr/bin/env to find ssh-add
This change is important when ssh-add is not inside /usr/bin e.g.
on NixOS.

Signed-off-by: Maximilian Güntner <code@maschinenpsychologe.de>
2016-09-03 20:49:55 +02:00
Piotr Gaczkowski
24ac1aa348 Clobber ssh environment regardless of setopt () 2016-08-21 00:02:58 +02:00
ncanceill
2c19c0e59e typo, fixes 2014-05-24 08:31:59 +02:00
Christian Höltje
cfe468f6f6 ssh-agent: prevent environment file from flapping
On an OS X laptop, the variable `$HOST` changes a lot depending
on what wifi network you're connected to.  This causes a lot
of `~/.ssh/environment-$HOST` files to be created and
causes multiple ssh-agents to created.

Instead, use `scutil --get ComputerName` to get something
more stable.
2014-03-13 14:44:58 -04:00
nishigori
dd4f57010c Fix bad ps syntax in ssh-agent plugin 2013-11-05 08:40:13 +09:00
Robby Russell
b2376c3770 Merge pull request from aquaplanet/fix-sshagent-openbsd
Fix ssh-agent plugin for OpenBSD, making it more portable
2013-11-04 12:29:42 -08:00
Armin Widegreen
5c529b5daa Fix ssh-agent plugin identities comment for using multiple identities. 2013-07-16 17:24:07 +02:00
Marcel Wolf
2a1c9ff340 add ssh-agent option to set default lifetime of identities
By default, ssh-agent stores identities forever. It has an option to
set a maximum lifetime for identites (useful to expire passphrase protected
keys). Allow this option to be set using:

zstyle :omz:plugins:ssh-agent lifetime <time>
2013-03-16 00:06:46 -04:00
Anders Andersson
1f4bb8deb7 OpenBSD doesn't have -ef flags for ps. Both linux and OpenBSD have -x flags which works just as greate here 2012-12-30 09:52:32 +01:00
gwjo
40b7f2099d Add support for loading mulitple identities 2011-06-04 22:34:49 -04:00
gwjo
35b879a17b Add support for agent forwarding 2011-06-04 22:34:17 -04:00
Theodore Robert Campbell Jr
9d991a5080 ssh-agent plugin now ends in "-$HOST" so an agent is started properly with nfs shared homes. 2011-03-01 01:38:12 -05:00
Robby Russell
26d97a9355 Reorganizing plugins so that each plugin has it's own directory now so that any plugin-specific functions can be bundled within there. 2010-09-30 21:34:06 -07:00