SSH Key Conversion to an OpenSSH compatible format

puttygen supports exporting your private key to an OpenSSH compatible format. You can then use OpenSSH tools to recreate the public key.

Open PuttyGen
Click Load
Load your private key
Go to Conversions->Export OpenSSH and export your private key
Copy your private key to ~/.ssh/id_dsa (or id_rsa).
Create the RFC 4716 version of the public key using ssh-keygen

ssh-keygen -e -f ~/.ssh/id_dsa > ~/.ssh/id_dsa_com.pub
Convert the RFC 4716 version of the public key to the OpenSSH format:

ssh-keygen -i -f ~/.ssh/id_dsa_com.pub > ~/.ssh/id_dsa.pub

Useful Net::SSH2 commands

#!/usr/bin/perl
use warnings;
use strict;
use Net::SSH2;
use Data::Dumper;

# see maillist archives at
# http://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users

my $ssh2 = Net::SSH2->new();
$ssh2->connect(‘localhost’) or die “Unable to connect Host $@ \n”;
#this works for passwords
#$ssh2->auth_password(‘z’,’ztester’) or die “Unable to login $@ \n”;

#do key authorization like commandline shell
# ssh -o PreferredAuthentications=publickey localhost
# See: http://cfm.gs.washington.edu/security/ssh/client-pkauth/
# for setting up the keys

# this dosn’t work
#$ssh2->auth(username=>’z’, interact => 1);

# so get the password for the key
use Term::ReadKey;
print “And your key password: “;
ReadMode(‘noecho’);
chomp(my $pass = ReadLine(0));
ReadMode(‘restore’);
print “\n”;

# works when run from z’s homedir because you need
# permission to read the keys
$ssh2->auth_publickey(‘z’,
‘/home/z/.ssh/id_dsa.pub’,
‘/home/z/.ssh/id_dsa’,
$pass );

#works
my $sftp = $ssh2->sftp();
my $fh = $sftp->open(‘/etc/passwd’) or die;
print $_ while <$fh>;

#my $chan = $ssh2->channel();
#$chan->blocking(0);
#$chan->exec(‘ls -la’);
#while (<$chan>){ print }

# to run a remote command in the background
# you need to semi-daemonize it by redirecting it’s filehandles
my $chan3 = $ssh2->channel();
$chan3->blocking(1);
$chan3->exec(“nohup /home/zentara/perlplay/net/zzsleep > foo.out 2> fo
+o.err < /dev/null &"); $chan3->send_eof;

#to run multiple commands use a shell
#shell use
my $chan = $ssh2->channel();
$chan->blocking(0);
$chan->shell();
print $chan “ls -la\n”;
print “LINE : $_” while <$chan>;
print $chan “who\n”;
print “LINE : $_” while <$chan>;
print $chan “date\n”;
print “LINE : $_” while <$chan>;

# file and directory operations
#will get dir named 2
#my $chan1 = $ssh2->channel();
#$chan1->exec(‘ls -la 2’);
#while (<$chan1>){ print }

# mkdir with sftp
#my $sftp = $ssh2->sftp();
my $dir = ‘/home/z/3’;
$sftp->mkdir($dir);
my %stat = $sftp->stat($dir);
print Dumper([\%stat]), “\n”;

#put a file
my $remote = “$dir/”.time;
$ssh2->scp_put($0, $remote);

#get a file
#use IO::Scalar;
#my $check = IO::Scalar->new;
#$ssh2->scp_get($remote, $check);
#print “$check\n\n”;

# get a dirlist
my $dir1 = ‘/home/z’;
my $dh = $sftp->opendir($dir1);
while(my $item = $dh->read) {
print $item->{‘name’},”\n”;
}

#shell use
my $chan2 = $ssh2->channel();
$chan2->blocking(0);
$chan2->shell();
print $chan2 “uname -a\n”;
print “LINE : $_” while <$chan2>;
print $chan2 “who\n”;
print “LINE : $_” while <$chan2>;
$chan2->close;

__END__

Compile Android on Cordova

set ANDROID_HOME=C:\Program Files\Android\android-sdk-windows

set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

Open a command line window, and go to /path/to/your/project/platforms/android/cordova.

cordova build android –release, from top level directory

Check ant.properties for the keystore details..

Also keygeneration:

keytool -genkeypair -dname "cn=Mark Jones, ou=JavaSoft, o=Sun, c=US" -alias xyu.com -keypass kpxx135 -keystore xyu.keystore

Debian Install Packages behind Firewall

apt-get --print-uris install mysql-server -y

Will print out the URL for the package and dependancies;

'http://mirrordirector.raspbian.org/raspbian/pool/main/liba/libaio/libaio1_0.3.109-3_armhf.deb' libaio1_0.3.109-3_armhf.deb 8944 MD5Sum:ddc43710db3f102df9477a8a95f025ad
'http://mirrordirector.raspbian.org/raspbian/pool/main/m/mysql-5.5/mysql-server-core-5.5_5.5.40-0+wheezy1_armhf.deb' mysql-server-core-5.5_5.5.40-0+wheezy1_armhf.deb 3060608 MD5Sum:9a8f4620799fcceb4567433caad2434e
'http://mirrordirector.raspbian.org/raspbian/pool/main/m/mysql-5.5/mysql-server-5.5_5.5.40-0+wheezy1_armhf.deb' mysql-server-5.5_5.5.40-0+wheezy1_armhf.deb 1729934 MD5Sum:98fe33dd64039ba120d1aa77e0992fa7
'http://mirrordirector.raspbian.org/raspbian/pool/main/h/heirloom-mailx/heirloom-mailx_12.5-2+deb7u1_armhf.deb' heirloom-mailx_12.5-2+deb7u1_armhf.deb 253508 MD5Sum:6155feba05b677f5f01eb5b53ae4ba2d
'http://mirrordirector.raspbian.org/raspbian/pool/main/libh/libhtml-template-perl/libhtml-template-perl_2.91-1_all.deb' libhtml-template-perl_2.91-1_all.deb 72020 MD5Sum:b25cc0a02e43fe4b5b46a01af3e98c4c
'http://mirrordirector.raspbian.org/raspbian/pool/main/m/mysql-5.5/mysql-server_5.5.40-0+wheezy1_all.deb' mysql-server_5.5.40-0+wheezy1_all.deb 73872 MD5Sum:b49873c3a32d33f6186e779202f6a87e

Cut out the URLs and put them into a file.

y=0;for x in `cat deps.txt`; do ssh username@192.168.8.111"wget -O - $x" >> $y.deb; y=$y+1; done

dpkg -i *.deb