Commit Graph

42 Commits

Author SHA1 Message Date
Marc Cornellà
1c879f67b4
fix(ssh-agent): silence ssh-add if quiet mode is enabled (#11201)
Fixes #11201
2022-10-03 16:58:42 +02:00
Marc Cornellà
60b89cd264
feat(ssh-agent): add quiet option to silence plugin (#9659)
Closes #9659

Co-authored-by: Jeff Warner <jeff@develops.software>
2021-11-17 09:55:39 +01:00
Marc Cornellà
f1dd97bb2a
fix(ssh-agent): fix check for running ssh-agent process with hidepid /proc (#8492)
Fixes #8492
2021-10-23 05:16:15 +02:00
Marc Cornellà
beeda72826
fix(ssh-agent): fix for bad zstyle command argument
Fixes #10282
2021-10-11 15:22:03 +02:00
Marc Cornellà
a0ac789f2a
feat(ssh-agent): allow lazy-loading SSH identities (#6309)
Fixes #7477
2021-10-11 12:15:47 +02:00
Marc Cornellà
735808f48d
Revert "feat(ssh-agent): only start ssh-agent once (#5359)"
This reverts commit 7692881d2a.
2021-09-10 18:01:43 +02:00
Marc Cornellà
4a69ee575c
feat(ssh-agent): allow specifying absolute path to identities
Fixes #9650
2021-08-27 18:08:04 +02:00
Marc Cornellà
3f0672ff94
refactor(ssh-agent): clean up and reorganize code 2021-08-26 14:56:22 +02:00
Marc Cornellà
7692881d2a
feat(ssh-agent): only start ssh-agent once (#5359)
Close #5359
Close #7379

Co-authored-by: Will Andrews <will@firepipe.net>
Co-authored-by: zhangyc <zhangyc@fenbi.com>
2021-08-26 14:54:17 +02:00
Simone Gaiarin
5a9d9553cd
feat(ssh-agent): allow using external helper to ask for passwords (#7631) 2021-08-26 11:42:17 +02:00
Marc Cornellà
3e7998aec3
Revert "ssh-agent: improvements (#6309)"
This reverts commit a206271460.
2021-06-14 10:57:50 +02:00
Nuno Goncalves
a206271460
ssh-agent: improvements (#6309)
* 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 #9701
2021-03-25 12:08:00 +01:00
Will Boyce
0e232d4853
feat(ssh-agent): add ssh-add-args setting (#7908)
* 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 (#7834) 2019-05-07 21:21:55 +02:00
Marc Cornellà
c494869632
ssh-agent: check for loaded id filenames first (#7521)
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 #7516.

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 (#7520) 2019-01-19 18:00:04 +01:00
Andreas
9329efd252 ssh-agent: autoload identities in one go (#7507)
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 #7506
2019-01-14 16:42:14 +01:00
François Scala
2a60385659 ssh-agent: use key signatures to check loaded ids (#7504)
Use fingerprint of ssh key instead of file name to control if the key is already loaded.

Also check for .ssh folder presence (#5128)
2019-01-14 16:38:45 +01:00
Marc Cornellà
fabee55948
ssh-agent: autoload identities not already loaded (#7174)
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 #3019
Fixes #6979
2019-01-09 21:19:52 +01:00
Michael Stucki
302270174d Use existing ssh-agent when invoking a sudo shell (#3891)
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à
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 #5418.
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 (#5322) 2016-08-21 00:02:58 +02:00
ncanceill
2c19c0e59e typo, fixes #1806 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 #1529 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