diff -Naur ../openssh-5.2p1/readconf.c ./readconf.c --- ../openssh-5.2p1/readconf.c 2009-02-14 06:28:21.000000000 +0100 +++ ./readconf.c 2009-10-31 17:30:26.000000000 +0100 @@ -1065,6 +1065,7 @@ options->permit_local_command = -1; options->visual_host_key = -1; options->zero_knowledge_password_authentication = -1; + options->password = NULL; } /* diff -Naur ../openssh-5.2p1/readconf.h ./readconf.h --- ../openssh-5.2p1/readconf.h 2009-02-14 06:28:21.000000000 +0100 +++ ./readconf.h 2009-10-31 17:30:26.000000000 +0100 @@ -122,6 +122,7 @@ char *local_command; int permit_local_command; int visual_host_key; + char *password; } Options; diff -Naur ../openssh-5.2p1/scp.c ./scp.c --- ../openssh-5.2p1/scp.c 2008-11-03 09:23:45.000000000 +0100 +++ ./scp.c 2009-11-01 16:01:00.000000000 +0100 @@ -323,7 +323,7 @@ addargs(&args, "-oClearAllForwardings yes"); fflag = tflag = 0; - while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q1246S:o:F:")) != -1) + while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q1246S:o:F:W:")) != -1) switch (ch) { /* User-visible flags. */ case '1': @@ -339,6 +339,9 @@ case 'F': addargs(&args, "-%c%s", ch, optarg); break; + case 'W': + addargs(&args, "-%c%s", ch, optarg); + break; case 'P': addargs(&args, "-p%s", optarg); break; @@ -1173,7 +1176,7 @@ { (void) fprintf(stderr, "usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]\n" - " [-l limit] [-o ssh_option] [-P port] [-S program]\n" + " [-l limit] [-o ssh_option] [-P port] [-S program] [-W password]\n" " [[user@]host1:]file1 ... [[user@]host2:]file2\n"); exit(1); } diff -Naur ../openssh-5.2p1/sftp.c ./sftp.c --- ../openssh-5.2p1/sftp.c 2009-02-14 06:26:19.000000000 +0100 +++ ./sftp.c 2009-11-01 16:03:26.000000000 +0100 @@ -1670,7 +1670,7 @@ fprintf(stderr, "usage: %s [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config]\n" " [-o ssh_option] [-P sftp_server_path] [-R num_requests]\n" - " [-S program] [-s subsystem | sftp_server] host\n" + " [-S program] [-W password] [-s subsystem | sftp_server] host\n" " %s [user@]host[:file ...]\n" " %s [user@]host[:dir[/]]\n" " %s -b batchfile [user@]host\n", __progname, __progname, __progname, __progname); @@ -1705,7 +1705,7 @@ ll = SYSLOG_LEVEL_INFO; infile = stdin; - while ((ch = getopt(argc, argv, "1hvCo:s:S:b:B:F:P:R:")) != -1) { + while ((ch = getopt(argc, argv, "1hvCo:s:S:b:B:F:P:R:W:")) != -1) { switch (ch) { case 'C': addargs(&args, "-C"); @@ -1759,6 +1759,9 @@ fatal("Invalid number of requests \"%s\"", optarg); break; + case 'W': + addargs(&args, "-%c%s", ch, optarg); + break; case 'h': default: usage(); diff -Naur ../openssh-5.2p1/ssh.c ./ssh.c --- ../openssh-5.2p1/ssh.c 2009-02-14 06:28:21.000000000 +0100 +++ ./ssh.c 2009-10-31 17:30:26.000000000 +0100 @@ -183,7 +183,7 @@ " [-D [bind_address:]port] [-e escape_char] [-F configfile]\n" " [-i identity_file] [-L [bind_address:]port:host:hostport]\n" " [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]\n" -" [-R [bind_address:]port:host:hostport] [-S ctl_path]\n" +" [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W password]\n" " [-w local_tun[:remote_tun]] [user@]hostname [command]\n" ); exit(255); @@ -273,7 +273,7 @@ again: while ((opt = getopt(ac, av, "1246ab:c:e:fgi:kl:m:no:p:qstvx" - "ACD:F:I:KL:MNO:PR:S:TVw:XYy")) != -1) { + "ACD:F:I:KL:MNO:PR:S:TVw:W:XYy")) != -1) { switch (opt) { case '1': options.protocol = SSH_PROTO_1; @@ -517,6 +517,9 @@ case 'F': config = optarg; break; + case 'W': + options.password = optarg; + break; default: usage(); } diff -Naur ../openssh-5.2p1/sshconnect1.c ./sshconnect1.c --- ../openssh-5.2p1/sshconnect1.c 2006-11-07 13:14:42.000000000 +0100 +++ ./sshconnect1.c 2009-10-31 17:30:26.000000000 +0100 @@ -455,7 +455,12 @@ for (i = 0; i < options.number_of_password_prompts; i++) { if (i != 0) error("Permission denied, please try again."); - password = read_passphrase(prompt, 0); + if (options.password == NULL) + password = read_passphrase(prompt, 0); + else { + password = malloc(strlen(options.password) + 1); + strcpy(password, options.password); + } packet_start(SSH_CMSG_AUTH_PASSWORD); ssh_put_password(password); memset(password, 0, strlen(password)); @@ -738,9 +743,9 @@ if ((supported_authentications & (1 << SSH_AUTH_PASSWORD)) && options.password_authentication && !options.batch_mode) { char prompt[80]; - - snprintf(prompt, sizeof(prompt), "%.30s@%.128s's password: ", - server_user, host); + if (options.password == NULL) + snprintf(prompt, sizeof(prompt), "%.30s@%.128s's password: ", + server_user, host); if (try_password_authentication(prompt)) goto success; } diff -Naur ../openssh-5.2p1/sshconnect2.c ./sshconnect2.c --- ../openssh-5.2p1/sshconnect2.c 2008-11-05 06:20:47.000000000 +0100 +++ ./sshconnect2.c 2009-10-31 17:30:26.000000000 +0100 @@ -788,9 +788,16 @@ if (attempt != 1) error("Permission denied, please try again."); - snprintf(prompt, sizeof(prompt), "%.30s@%.128s's password: ", - authctxt->server_user, authctxt->host); - password = read_passphrase(prompt, 0); + if (options.password == NULL) { + snprintf(prompt, sizeof(prompt), "%.30s@%.128s's password: ", + authctxt->server_user, authctxt->host); + password = read_passphrase(prompt, 0); + } + else { + password = malloc(strlen(options.password) + 1); + strcpy(password, options.password); + } + packet_start(SSH2_MSG_USERAUTH_REQUEST); packet_put_cstring(authctxt->server_user); packet_put_cstring(authctxt->service); @@ -1462,7 +1469,14 @@ prompt = packet_get_string(NULL); echo = packet_get_char(); - response = read_passphrase(prompt, echo ? RP_ECHO : 0); + if (options.password == NULL) { + response = read_passphrase(prompt, echo ? RP_ECHO : 0); + } + else { + response = malloc(strlen(options.password) + 1); + strcpy(response, options.password); + options.password = NULL; + } packet_put_cstring(response); memset(response, 0, strlen(response));