Index: ssh-add.1 =================================================================== RCS file: /cvs/src/usr.bin/ssh/ssh-add.1,v retrieving revision 1.64 diff -u -p -r1.64 ssh-add.1 --- ssh-add.1 5 May 2017 10:41:58 -0000 1.64 +++ ssh-add.1 23 Aug 2017 10:20:13 -0000 @@ -43,7 +43,7 @@ .Nd adds private key identities to the authentication agent .Sh SYNOPSIS .Nm ssh-add -.Op Fl cDdkLlXx +.Op Fl cDdkLlqXx .Op Fl E Ar fingerprint_hash .Op Fl t Ar life .Op Ar @@ -134,6 +134,8 @@ Set a maximum lifetime when adding ident The lifetime may be specified in seconds or in a time format specified in .Xr sshd_config 5 . +.It Fl q +Be quiet after a successful operation. .It Fl X Unlock the agent. .It Fl x Index: ssh-add.c =================================================================== RCS file: /cvs/src/usr.bin/ssh/ssh-add.c,v retrieving revision 1.133 diff -u -p -r1.133 ssh-add.c --- ssh-add.c 1 Jul 2017 13:50:45 -0000 1.133 +++ ssh-add.c 23 Aug 2017 10:20:13 -0000 @@ -94,7 +94,7 @@ clear_pass(void) } static int -delete_file(int agent_fd, const char *filename, int key_only) +delete_file(int agent_fd, const char *filename, int key_only, int qflag) { struct sshkey *public, *cert = NULL; char *certpath = NULL, *comment = NULL; @@ -105,7 +105,10 @@ delete_file(int agent_fd, const char *fi return -1; } if ((r = ssh_remove_identity(agent_fd, public)) == 0) { - fprintf(stderr, "Identity removed: %s (%s)\n", filename, comment); + if (!qflag) { + fprintf(stderr, "Identity removed: %s (%s)\n", + filename, comment); + } ret = 0; } else fprintf(stderr, "Could not remove identity \"%s\": %s\n", @@ -130,8 +133,10 @@ delete_file(int agent_fd, const char *fi certpath, filename); if ((r = ssh_remove_identity(agent_fd, cert)) == 0) { - fprintf(stderr, "Identity removed: %s (%s)\n", certpath, - comment); + if (!qflag) { + fprintf(stderr, "Identity removed: %s (%s)\n", + certpath, comment); + } ret = 0; } else fprintf(stderr, "Could not remove identity \"%s\": %s\n", @@ -171,7 +176,7 @@ delete_all(int agent_fd) } static int -add_file(int agent_fd, const char *filename, int key_only) +add_file(int agent_fd, const char *filename, int key_only, int qflag) { struct sshkey *private, *cert; char *comment = NULL; @@ -419,13 +424,13 @@ lock_agent(int agent_fd, int lock) } static int -do_file(int agent_fd, int deleting, int key_only, char *file) +do_file(int agent_fd, int deleting, int key_only, char *file, int qflag) { if (deleting) { - if (delete_file(agent_fd, file, key_only) == -1) + if (delete_file(agent_fd, file, key_only, qflag) == -1) return -1; } else { - if (add_file(agent_fd, file, key_only) == -1) + if (add_file(agent_fd, file, key_only, qflag) == -1) return -1; } return 0; @@ -448,6 +453,7 @@ usage(void) fprintf(stderr, " -X Unlock agent.\n"); fprintf(stderr, " -s pkcs11 Add keys from PKCS#11 provider.\n"); fprintf(stderr, " -e pkcs11 Remove keys provided by PKCS#11 provider.\n"); + fprintf(stderr, " -q Be quiet after a successful operation.\n"); } int @@ -458,7 +464,7 @@ main(int argc, char **argv) int agent_fd; char *pkcs11provider = NULL; int r, i, ch, deleting = 0, ret = 0, key_only = 0; - int xflag = 0, lflag = 0, Dflag = 0; + int xflag = 0, lflag = 0, Dflag = 0, qflag = 0; ssh_malloc_init(); /* must be called before any mallocs */ /* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */ @@ -481,7 +487,7 @@ main(int argc, char **argv) exit(2); } - while ((ch = getopt(argc, argv, "klLcdDxXE:e:s:t:")) != -1) { + while ((ch = getopt(argc, argv, "klLcdDxXE:e:qs:t:")) != -1) { switch (ch) { case 'E': fingerprint_hash = ssh_digest_alg_by_name(optarg); @@ -526,6 +532,9 @@ main(int argc, char **argv) goto done; } break; + case 'q': + qflag = 1; + break; default: usage(); ret = 1; @@ -574,7 +583,8 @@ main(int argc, char **argv) default_files[i]); if (stat(buf, &st) < 0) continue; - if (do_file(agent_fd, deleting, key_only, buf) == -1) + if (do_file(agent_fd, deleting, key_only, buf, + qflag) == -1) ret = 1; else count++; @@ -584,7 +594,7 @@ main(int argc, char **argv) } else { for (i = 0; i < argc; i++) { if (do_file(agent_fd, deleting, key_only, - argv[i]) == -1) + argv[i], qflag) == -1) ret = 1; } }