summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2011-10-18 16:06:33 +1100
committerDamien Miller <djm@mindrot.org>2011-10-18 16:06:33 +1100
commit8f4279e4ab6fdc3245fe9c80e363a2f5bdf01d4f (patch)
tree2578eb44c9e6cdd8adf226921ece9caff8227ea4
parentc51a5ab2c6f7ea4ae42e70d1d00bdf57c28f8c36 (diff)
- djm@cvs.openbsd.org 2011/10/18 05:00:48
[ssh-add.1 ssh-add.c] new "ssh-add -k" option to load plain keys (skipping certificates); "looks ok" markus@
-rw-r--r--ChangeLog4
-rw-r--r--ssh-add.19
-rw-r--r--ssh-add.c27
3 files changed, 27 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 583f88f22..1ff341719 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,10 @@
16 [auth-options.c key.c] 16 [auth-options.c key.c]
17 remove explict search for \0 in packet strings, this job is now done 17 remove explict search for \0 in packet strings, this job is now done
18 implicitly by buffer_get_cstring; ok markus 18 implicitly by buffer_get_cstring; ok markus
19 - djm@cvs.openbsd.org 2011/10/18 05:00:48
20 [ssh-add.1 ssh-add.c]
21 new "ssh-add -k" option to load plain keys (skipping certificates);
22 "looks ok" markus@
19 23
2020111001 2420111001
21 - (dtucker) [openbsd-compat/mktemp.c] Fix compiler warning. ok djm 25 - (dtucker) [openbsd-compat/mktemp.c] Fix compiler warning. ok djm
diff --git a/ssh-add.1 b/ssh-add.1
index fd48ff98f..aec620dea 100644
--- a/ssh-add.1
+++ b/ssh-add.1
@@ -1,4 +1,4 @@
1.\" $OpenBSD: ssh-add.1,v 1.55 2010/10/28 18:33:28 jmc Exp $ 1.\" $OpenBSD: ssh-add.1,v 1.56 2011/10/18 05:00:48 djm Exp $
2.\" 2.\"
3.\" Author: Tatu Ylonen <ylo@cs.hut.fi> 3.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -35,7 +35,7 @@
35.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 35.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37.\" 37.\"
38.Dd $Mdocdate: October 28 2010 $ 38.Dd $Mdocdate: October 18 2011 $
39.Dt SSH-ADD 1 39.Dt SSH-ADD 1
40.Os 40.Os
41.Sh NAME 41.Sh NAME
@@ -43,7 +43,7 @@
43.Nd adds private key identities to the authentication agent 43.Nd adds private key identities to the authentication agent
44.Sh SYNOPSIS 44.Sh SYNOPSIS
45.Nm ssh-add 45.Nm ssh-add
46.Op Fl cDdLlXx 46.Op Fl cDdkLlXx
47.Op Fl t Ar life 47.Op Fl t Ar life
48.Op Ar 48.Op Ar
49.Nm ssh-add 49.Nm ssh-add
@@ -110,6 +110,9 @@ and retry.
110.It Fl e Ar pkcs11 110.It Fl e Ar pkcs11
111Remove keys provided by the PKCS#11 shared library 111Remove keys provided by the PKCS#11 shared library
112.Ar pkcs11 . 112.Ar pkcs11 .
113.It Fl k
114When loading keys into the agent, load plain private keys only and skip
115certificates.
113.It Fl L 116.It Fl L
114Lists public key parameters of all identities currently represented 117Lists public key parameters of all identities currently represented
115by the agent. 118by the agent.
diff --git a/ssh-add.c b/ssh-add.c
index 6d5e2a957..ea7619e6a 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-add.c,v 1.101 2011/05/04 21:15:29 djm Exp $ */ 1/* $OpenBSD: ssh-add.c,v 1.102 2011/10/18 05:00:48 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -139,11 +139,11 @@ delete_all(AuthenticationConnection *ac)
139} 139}
140 140
141static int 141static int
142add_file(AuthenticationConnection *ac, const char *filename) 142add_file(AuthenticationConnection *ac, const char *filename, int key_only)
143{ 143{
144 Key *private, *cert; 144 Key *private, *cert;
145 char *comment = NULL; 145 char *comment = NULL;
146 char msg[1024], *certpath; 146 char msg[1024], *certpath = NULL;
147 int fd, perms_ok, ret = -1; 147 int fd, perms_ok, ret = -1;
148 Buffer keyblob; 148 Buffer keyblob;
149 149
@@ -219,6 +219,9 @@ add_file(AuthenticationConnection *ac, const char *filename)
219 fprintf(stderr, "Could not add identity: %s\n", filename); 219 fprintf(stderr, "Could not add identity: %s\n", filename);
220 } 220 }
221 221
222 /* Skip trying to load the cert if requested */
223 if (key_only)
224 goto out;
222 225
223 /* Now try to add the certificate flavour too */ 226 /* Now try to add the certificate flavour too */
224 xasprintf(&certpath, "%s-cert.pub", filename); 227 xasprintf(&certpath, "%s-cert.pub", filename);
@@ -253,7 +256,8 @@ add_file(AuthenticationConnection *ac, const char *filename)
253 if (confirm != 0) 256 if (confirm != 0)
254 fprintf(stderr, "The user must confirm each use of the key\n"); 257 fprintf(stderr, "The user must confirm each use of the key\n");
255 out: 258 out:
256 xfree(certpath); 259 if (certpath != NULL)
260 xfree(certpath);
257 xfree(comment); 261 xfree(comment);
258 key_free(private); 262 key_free(private);
259 263
@@ -347,13 +351,13 @@ lock_agent(AuthenticationConnection *ac, int lock)
347} 351}
348 352
349static int 353static int
350do_file(AuthenticationConnection *ac, int deleting, char *file) 354do_file(AuthenticationConnection *ac, int deleting, int key_only, char *file)
351{ 355{
352 if (deleting) { 356 if (deleting) {
353 if (delete_file(ac, file) == -1) 357 if (delete_file(ac, file) == -1)
354 return -1; 358 return -1;
355 } else { 359 } else {
356 if (add_file(ac, file) == -1) 360 if (add_file(ac, file, key_only) == -1)
357 return -1; 361 return -1;
358 } 362 }
359 return 0; 363 return 0;
@@ -383,7 +387,7 @@ main(int argc, char **argv)
383 extern int optind; 387 extern int optind;
384 AuthenticationConnection *ac = NULL; 388 AuthenticationConnection *ac = NULL;
385 char *pkcs11provider = NULL; 389 char *pkcs11provider = NULL;
386 int i, ch, deleting = 0, ret = 0; 390 int i, ch, deleting = 0, ret = 0, key_only = 0;
387 391
388 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ 392 /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
389 sanitise_stdfd(); 393 sanitise_stdfd();
@@ -400,8 +404,11 @@ main(int argc, char **argv)
400 "Could not open a connection to your authentication agent.\n"); 404 "Could not open a connection to your authentication agent.\n");
401 exit(2); 405 exit(2);
402 } 406 }
403 while ((ch = getopt(argc, argv, "lLcdDxXe:s:t:")) != -1) { 407 while ((ch = getopt(argc, argv, "klLcdDxXe:s:t:")) != -1) {
404 switch (ch) { 408 switch (ch) {
409 case 'k':
410 key_only = 1;
411 break;
405 case 'l': 412 case 'l':
406 case 'L': 413 case 'L':
407 if (list_identities(ac, ch == 'l' ? 1 : 0) == -1) 414 if (list_identities(ac, ch == 'l' ? 1 : 0) == -1)
@@ -467,7 +474,7 @@ main(int argc, char **argv)
467 default_files[i]); 474 default_files[i]);
468 if (stat(buf, &st) < 0) 475 if (stat(buf, &st) < 0)
469 continue; 476 continue;
470 if (do_file(ac, deleting, buf) == -1) 477 if (do_file(ac, deleting, key_only, buf) == -1)
471 ret = 1; 478 ret = 1;
472 else 479 else
473 count++; 480 count++;
@@ -476,7 +483,7 @@ main(int argc, char **argv)
476 ret = 1; 483 ret = 1;
477 } else { 484 } else {
478 for (i = 0; i < argc; i++) { 485 for (i = 0; i < argc; i++) {
479 if (do_file(ac, deleting, argv[i]) == -1) 486 if (do_file(ac, deleting, key_only, argv[i]) == -1)
480 ret = 1; 487 ret = 1;
481 } 488 }
482 } 489 }