From: ESRY JR., D. <de...@at...> - 2015-03-31 19:38:01
|
Ugh, special characters... The password command should be giving you an error if there is something wrong with your input. Turn on the logging and see if you can catch an error. my $filename = "/var/tmp/expect_script.log"; $ssh->log_file($filename, 'w'); It also might be that you need to send a newline character when you send it the password command $ssh->send("passwd amagana\n"); If you are getting in as root then you are getting very close. -----Original Message----- From: MAGANA, ANDREAS S I CTR USAF AFMC 72 ABW/SCOOT [mailto:and...@us...] Sent: Tuesday, March 31, 2015 3:18 PM To: ESRY JR., DON Cc: exp...@li... Subject: RE: expect.pm not updating password It is still not changing my password is it because my password has some special characters? Should I escape the special characters? Oh by the way the logs on the remote solaris box say its successfully ssh'ing and su'ing to root but that's it and then I try on the remote box to use my new password but it is still taking my old password for amagana. I changed the script to get it this far: #!/usr/bin/perl use strict; use Expect; my $ssh = Expect->new('ssh amagana@remotehost;'); $ssh->debug(1); $ssh->expect(60, 'Password:'); $ssh->send("mycurrentpassword\n"); $ssh->expect(60, '$'); $ssh->send("su - root\n"); $ssh->expect(60, 'Password:'); $ssh->send("myrootpassword\n"); $ssh->expect(60, '#'); $ssh->send("passwd amagana"); $ssh->expect(60, 'New Password:'); $ssh->send("mynewpassword\n"); $ssh->expect(60, 'Re-enter new Password:'); $ssh->send("mynewpassword\n"); $ssh->send("exit\n"); $ssh->close(); On the target remote solaris server: Accepted keyboard-interactive for amagana from x.x.x.x port xxxxx ssh2 'su root' succeeded for amagana on /dev/pts/3 //SIGNED// Andy Magaña UNIX Systems Administrator Diligent Contractor, 72nd Air Base Wing Tinker Air Force Base, Oklahoma Commercial: (405) 734-0341 -----Original Message----- From: ESRY JR., DON [mailto:de...@at...] Sent: Tuesday, March 31, 2015 1:54 PM To: MAGANA, ANDREAS S I CTR USAF AFMC 72 ABW/SCOOT; exp...@li... Subject: RE: expect.pm not updating password That looks like it worked. Did it change your password? A couple of things that might be helpful for you. I'm not sure that you really want that newline character in your first pattern match right after you set the debug value $ssh->expect("Password:\n"); $ssh->send("mycurrentpassword\n"); I think you should try: $ssh->expect("Password:"); $ssh->send("mycurrentpassword\n"); You can have it log everything to file by inserting something like: my $filename = "/var/tmp/expect_script.log"; $ssh->log_file($filename); # this will keep old data and append new to the end Or $ssh->log_file($filename, 'w'); # this will wipe out old data from previous runs I think there is an stty setting you can play around with so that you can see what the password command suppresses. Maybe it is stty -echo but you will have to login and get the shell prompt before you can send this command. -----Original Message----- From: MAGANA, ANDREAS S I CTR USAF AFMC 72 ABW/SCOOT [mailto:and...@us...] Sent: Tuesday, March 31, 2015 1:53 PM To: ESRY JR., DON; exp...@li... Subject: RE: expect.pm not updating password Okay thank you for your attention I have turned on debugging to 1 like this $ssh->debug(1); and this is what I get. Starting EXPECT pattern matching... at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561 Expect::expect('Expect=GLOB(0x89c0390)', 'Password:\x{a}') called at ./tester-a line 8 Starting EXPECT pattern matching... at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561 Expect::expect('Expect=GLOB(0x89c0390)', '$') called at ./tester-a line 10 mypassword Starting EXPECT pattern matching... at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561 Expect::expect('Expect=GLOB(0x89c0390)', 'Password:') called at ./tester-a line 12 su - root Starting EXPECT pattern matching... at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561 Expect::expect('Expect=GLOB(0x89c0390)', '#') called at ./tester-a line 14 rootpassword Starting EXPECT pattern matching... at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561 Expect::expect('Expect=GLOB(0x89c0390)', 'New Password:\x{a}') called at ./tester-a line 16 passwd amagana Starting EXPECT pattern matching... at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 561 Expect::expect('Expect=GLOB(0x89c0390)', 'Re-enter new Password:\x{a}') called at ./tester-a line 18 mynewpassword Closing spawn id(3). at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 1431 Expect::hard_close('Expect=GLOB(0x89c0390)') called at /usr/lib/perl5/site_perl/5.8.8/Expect.pm line 1621 Expect::DESTROY('Expect=GLOB(0x89c0390)') called at ./tester-a line 0 eval {...} called at ./tester-a line 0 spawn id(3) closed. Pid 1218 of spawn id(3) terminated, Status: 0x01 //SIGNED// Andy Magaña UNIX Systems Administrator Diligent Contractor, 72nd Air Base Wing Tinker Air Force Base, Oklahoma Commercial: (405) 734-0341 -----Original Message----- From: ESRY JR., DON [mailto:de...@at...] Sent: Tuesday, March 31, 2015 11:15 AM To: MAGANA, ANDREAS S I CTR USAF AFMC 72 ABW/SCOOT; exp...@li... Subject: RE: expect.pm not updating password I don't see a question in your email. What do you see on your screen when you run it? -----Original Message----- From: MAGANA, ANDREAS S I CTR USAF AFMC 72 ABW/SCOOT [mailto:and...@us...] Sent: Tuesday, March 31, 2015 12:01 PM To: exp...@li... Subject: [Expectperl-discuss] expect.pm not updating password I am a novice and have a expect.pm script that is supposed to ssh to remote host and change my password on a Sparc Solaris 10 server. #!/usr/bin/perl use strict; use Expect; my $ssh = Expect->new('ssh mylogin@remotehost'); $ssh->debug(0); $ssh->expect("Password:\n"); $ssh->send("mycurrentpassword\n"); $ssh->expect('$'); $ssh->send("su - root\n"); $ssh->expect("Password:"); $ssh->send("myrootpassword\n"); $ssh->expect('#'); $ssh->send("passwd mylogin\n"); $ssh->expect("New Password:\n"); $ssh->send("mynewpassword\n"); $ssh->expect("Re-enter new Password:\n"); $ssh->send("mynewpassword\n"); #$ssh->expect #$ssh->close(); //SIGNED// Andy Magaña UNIX Systems Administrator Diligent Contractor, 72nd Air Base Wing Tinker Air Force Base, Oklahoma Commercial: (405) 734-0341 -----Original Message----- From: openssl-users [mailto:ope...@op...] On Behalf Of ope...@op... Sent: Wednesday, March 18, 2015 12:36 PM To: ope...@op... Subject: openssl-users Digest, Vol 4, Issue 23 Send openssl-users mailing list submissions to ope...@op... To subscribe or unsubscribe via the World Wide Web, visit https://mta.openssl.org/mailman/listinfo/openssl-users or, via email, send a message with subject or body 'help' to ope...@op... You can reach the person managing the list at ope...@op... When replying, please edit your Subject line so it is more specific than "Re: Contents of openssl-users digest..." Today's Topics: 1. Re: base64 decode in C (Jakob Bohm) 2. Re: base64 decode in C (Walter H.) 3. Re: [openssl-announce] Forthcoming OpenSSL releases (Dr. Matthias St. Pierre) 4. Re: base64 decode in C (Scott Neugroschl) ---------------------------------------------------------------------- Message: 1 Date: Wed, 18 Mar 2015 17:33:41 +0100 From: Jakob Bohm <jb-...@wi...> To: ope...@op... Subject: Re: [openssl-users] base64 decode in C Message-ID: <550...@wi...> Content-Type: text/plain; charset=windows-1252; format=flowed Please refer to Dave Thompson's answer, it describes your problem. On 18/03/2015 16:08, Prashant Bapat wrote: > Hi Dave and Walter, > > Thanks for our reply. > > I'm not doing anything different for the ssh pubkey. I'm able to > decode it using the "openssl enc -base64 -d -A" command. But not using > the C program. > > Attaching my entire code here. After getting the base64 decoded I'm > calculating the MD5 sum and printing it. This works for a regular > string but not for SSH pubkey. > > Thanks again. > > --Prashant > Enjoy Jakob -- Jakob Bohm, CIO, Partner, WiseMo A/S. http://www.wisemo.com Transformervej 29, 2860 S?borg, Denmark. Direct +45 31 13 16 10 This public discussion message is non-binding and may contain errors. WiseMo - Remote Service Management for PCs, Phones and Embedded ------------------------------ Message: 2 Date: Wed, 18 Mar 2015 17:40:06 +0100 From: "Walter H." <Wal...@ma...> To: ope...@op... Subject: Re: [openssl-users] base64 decode in C Message-ID: <550...@ma...> Content-Type: text/plain; charset="utf-8"; Format="flowed" On 18.03.2015 16:08, Prashant Bapat wrote: > printf("Base64 decoded string is : %s\n", b64_decode(str, > strlen(str))); // This should print binary for a ssh key. not really, because the return of b64_decode is not a C string; and the format specfier %s expects a C string; -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 5971 bytes Desc: S/MIME Cryptographic Signature URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20150318/f066e41 6/attachment-0001.bin> ------------------------------ Message: 3 Date: Wed, 18 Mar 2015 17:59:59 +0100 From: "Dr. Matthias St. Pierre" <Mat...@nc...> To: <ope...@op...> Subject: Re: [openssl-users] [openssl-announce] Forthcoming OpenSSL releases Message-ID: <550...@nc...> Content-Type: text/plain; charset="windows-1252" Thanks for the three line upgracde recipe in https://wiki.openssl.org/index.php/Code_reformatting It's as simple as you stated, indeed. The reformatting was a good thing to do. Also, it makes sense to me to apply it to all stable branches uniformly, in order to simplify cross-branch merging. msp On 03/18/2015 04:32 PM, Salz, Rich wrote: >> The extra work is also documented (in a place not linked from the >> wiki) for >> those who maintain a git fork of the OpenSSL repository. > > I just tossed together https://wiki.openssl.org/index.php/Code_reformatting > Found off the main page, https://wiki.openssl.org/index.php/Main_Page#Internals_and_Development > >> But I have not yet seen a meaningful recipe for those of us who >> maintain a >> traditional set of feature patches against the released tarballs, >> nicely organized for future contribution. > > Folks had months of warning that this was going to happen. And, > frankly, patches did not come flooding into the team. > > But I hope the above link helps. > > /r$ > > _______________________________________________ > openssl-users mailing list > To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users > ------------------------------ Message: 4 Date: Wed, 18 Mar 2015 17:26:39 +0000 From: Scott Neugroschl <sc...@xy...> To: "ope...@op..." <ope...@op...> Subject: Re: [openssl-users] base64 decode in C Message-ID: <D358E5B1511A314F8160ADC6F3754987069FD9F8@XYSVEX01.XYPRO-23.LOCAL> Content-Type: text/plain; charset="utf-8" I believe the SSH pubkey is binary data, not ASCII, so strlen() will not work on it if it has embedded NUL chars. As Dave Thompson suggested, instead of strlen(), use the length returned from BIO_read. From: openssl-users [mailto:ope...@op...] On Behalf Of Prashant Bapat Sent: Wednesday, March 18, 2015 8:08 AM To: openssl-users Subject: Re: [openssl-users] base64 decode in C Hi Dave and Walter, Thanks for our reply. I'm not doing anything different for the ssh pubkey. I'm able to decode it using the "openssl enc -base64 -d -A" command. But not using the C program. Attaching my entire code here. After getting the base64 decoded I'm calculating the MD5 sum and printing it. This works for a regular string but not for SSH pubkey. Thanks again. --Prashant On 18 March 2015 at 18:04, Walter H. <Wal...@ma...<mailto:Wal...@ma...>> wrote: Hi, before calling this function, remove any whitespace; Walter _______________________________________________ openssl-users mailing list To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20150318/a6cff62 3/attachment.html> ------------------------------ Subject: Digest Footer _______________________________________________ openssl-users mailing list ope...@op... https://mta.openssl.org/mailman/listinfo/openssl-users ------------------------------ End of openssl-users Digest, Vol 4, Issue 23 ******************************************** |