Tuesday, April 17, 2007

Script to exchange ssh keys

 1 #!/usr/bin/perl
2 use Expect;
3 #USAGE: ssh-key-exchange.pl <IP> <USERNAME> <PASSWORD>
4
5 my $ip = $ARGV[0];
6 my $login = $ARGV[ 1];
7 my $password = $ARGV[2 ];
8 my $private_key='/root/.ssh/id_rsa ';
9 my $public_key='/root/.ssh/id_rsa.pub ';
10 my $authorisedkeyfile='/root/.ssh/authorized_keys ';
11 my $timeout = 10;
12 my $aft = new Expect;
13
14 #Generate the public and private key on the local m/c A
15 if(!(( -e $public_key ) &&( -e $private_key ))) {
16 print "Generating the Public and Private Key:\n ";
17 @result=`ssh-keygen -t rsa -f /root/.ssh/id_rsa -P "" `;
18 #print @result;
19 }
20 #Copy the file to m/c B
21 print "Copying Public Key from A to B.\n ";
22 $aft->spawn("scp $public_key $login\@$ip:/tmp/");
23 $aft->expect($timeout,[ qr'\? $' , sub { my $fh=shift; $fh->send("yes\n"); exp_continue; } ],
24 [ 'Password: $',sub { my $fh=shift;$fh->send("$password \n");exp_continue;} ],
25 # '-re','\# $'
26 );
27 $aft->do_soft_close();
28
29
30 #Add Keys to authorised keys in B
31 print " Adding Keys to authorised key in B with IP=$ip,[ $login $password ] \n";
32 my $aft = new Expect;
33 $aft->log_file("/tmp/expect_log" ,"w");
34 $aft->spawn( "ssh $login\@$ip") or die "Cannot ssh to the machine \n";
35 $aft->expect($timeout,[ qr'\? $', sub { my $fh=shift;$fh ->send("yes\n"); exp_continue; } ],
36 [ 'Password: $',sub { my $fh=shift;$fh->send("$password\n ");exp_continue;} ],
37 '-re', '\# $'
38 );
39 $aft ->send("touch $authorisedkeyfile\n");
40 $aft->expect($timeout,'-re' ,'\# $');
41 $aft->send( "cat /tmp/id_rsa.pub >> $authorisedkeyfile\n");
42 $aft->expect($timeout,'-re', '\# $');
43 $aft->send(" exit\n");
44 $aft->do_soft_close();
45

4 comments:

Anonymous said...

I found useful tutorial blog that contains many software, tools, scripts to hack e-gold, paypal, ATM, credit cards and thousands valid credit card accounts as well as Paypal. This blog also sell many softwares that might be useful for hackers and carders. Check this blog:
http://www.hacking-egold.co.cc/

Chaoooo.....

Palm Pixi Plus Verizon Only Cell Phone with WebOS, Touch Screen said...

good article

Dark Reviews said...


Hello
I have got a legit cc vendor in youtube. I think a lot of people like me is getting scammed every time thats why I'm sharing my knowledge to increasing awareness.
░▒▓█►👌 Best Darkweb reviews for Carding with legit site 👌◄█▓▒░
░▒▓█►👌 https://youtu.be/8sJ-RhgfoGY 👌◄█▓▒░
░▒▓█►👌 Best Darkweb reviews for Carding with legit site 👌◄█▓▒░
░▒▓█►👌 https://youtu.be/8sJ-RhgfoGY 👌◄█▓▒░
░▒▓█►👌 Best Darkweb reviews for Carding with legit site 👌◄█▓▒░
░▒▓█►👌 https://youtu.be/8sJ-RhgfoGY 👌◄█▓▒░

Unknown said...

Legit & Scam Vendors Reviews on youtube: 100% Legit Vendors Reviews 2020

Legit Vendor on Darkweb: Watch Youtube Video
https://youtu.be/DFvRFCG_DHI
Legit Vendor on Darkweb: Watch Youtube Video
https://youtu.be/DFvRFCG_DHI
Legit Vendor on Darkweb: Watch Youtube Video
https://youtu.be/DFvRFCG_DHI
Legit Vendor on Darkweb: Watch Youtube Video
https://youtu.be/DFvRFCG_DHI