scp-in remote rails server

Yesterday I was trying to scp some of the logs from Rails EC2 Server, for my colleague. For a long time the scp dint work exiting with status 1. It also gave only a cryptic message as output saying “Using System Ruby Now”.

I couldn’t figure what the problem might be, expecting something to be messing from the client side{My local machine}. verbose scp output


...
debug1: Sending command: scp -v -f -- /****/shared/log/logfile.log
Sink: Now using system ruby.
Now using system ruby.
➜ staging-de1 Sending file modes: C0664 1583336 logfile.log
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
...

gave some hints that the remote system was sending to “Sink”, my machine instead of the file, output “Now using system ruby”

Evidently, while we checked the server, these existed a “rvm use” call in the bashrc file, that lead to echo the above output on every login.

Strangely enough, I thought scp should have handled this by purging the terminal output, but it didn’t.

So later the scp was successful, after the echo was removed.

Hope, scp in future introduces feature that purges this kind of output from shell, to honor only the file contents.

GSoC Mid-Term Report

This post tries to provide a brief update about the last months explorations around krypt.

Some of the things I tried touching over the month:

RIPEMD160

Fix Digest with above

Lay Cipher Prototype Implementation

Provide Cipher JCE Implementation

Provide Streaming Base64 Implementation and of course READ A LOT.

=====

I l try laying out first what and how, I had to read and understand, and lay the prototype implementations.

It all started by reading the Bouncy Castle Implementations to get to know better about the whole implementation for Crypto and Digest. I then moved on to understand how actually krypt-core-java and krypt-jce-provider worked, where my actual work was going to be.

My coding began by providing RIPEMD160 implementation to the jce-provider. Again this was hugely based on the BC Impl. Next I made a hook in the jce for the RIPEMD call.

The next thing was laying the Cipher JCE interface based on terms with the Digest. This still need work, with proper and full definitions. {More on this later}

In the meanwhile Martin, integrated Base64 and Hex Streaming implementations. So I move on to read what they did, and how they interfaced with the Ruby world. At this point of time, I really started to looking into how Java was  being exposed to the Ruby world.

There were some crazy times over here, where I wasn’t able to figure out key issues of exposure, like Method argument handling, block handling, arrays, byte handling among a long list. This made me actually look deeply into plugin development for JRuby. I plan to do some documentation work on this, with lots of help from the JRuby community soon.

It was awesome to get an example implementation of how Martin wanted, by his Hex impl. So I later ported Base64 based on the same, for streaming impl. This was one of the “tasks”, that was on the platter to complete.

Next I move on to Ciphers on krypt-core. It was a huge help from jruby-ossl, that gave a perfect interface for the OpenSSL::Cipher ruby module. I ported the same, to provide prototype implementation with full cross-compatibility, with the Ruby version. But again this was a self contained version, meaning it used its own way on instantiation Ciphers, and that was a blocker, since we wanted them to be provided over by JCE. {We wanted to remove the BC Provider Dependencies that jruby-ossl currently relies on}

So that’s one of the TODO’s , to move on to use the exported functionality from krypt-jce, for Cipher interface.

I was to write specs for Cipher, which I was onto, when my machine crashed. And now have started to work on them, after a full revamp of my Machine.

Summary

In all most of my work was surrounded on reading and understanding and then doing small bits to be supported by Krypt. It was an awesome month, and if the evaluations go through, the next month would be even awesomer!

Ahead

If all goes fine, Martin will be laying out the IO impl that we want to base the Signature’s for safely working on password storage in memory{or the avoidance of the same}. Once he does that, I l try using the underlying architecture JRuby already provides, to emulate what Martin will implement.

Then on it will be implementing  Signatures themselves. The implementation of the same would then decide our journey ahead.

Mysql2 gem Error

Today while working with mysql2 gem, I ran into

“SL connection error: error:00000001:lib(0):func(0):reason(1)”

which was specific to only my machine, apart from the other devs.

I have Mac OS X, with rbenv managing my rubies. I was using brew as the package manager.

I was trying to access remote database over mysql2 connect. I went on to read the internals of mysql2, which gave no answers, and then onto the openssl gem form ruby sources, with vain.

Finally, what gave way was unistalling and unlinking openssl package from brew. After which reinstalling my ruby, gave way for accessing without certificate errors.

I l need to search more, for what was messing up with the whole setup, but somehow my ruby was using wrong paths for .pem files, from brew installation.

Quick into it

So the past few days its been reading and reading and more reading. Because crypto wasn’t going to be easy they say.

Although we’ve been able scratch the surface on some things. Some things are still in the grey for me{Many!}.

I integrated RIPMD160 implementation into krypt-digests. Although I need to re factor the beauty.

Defined a prototype for Ciphers. It exposes blowfish, aes, des, rsa, ecies for now, with default padding and mode for now. I have setup architectures for these, still waiting for Martin to define the interfaces into LibraryService for integration.

The next thing after Ciphers we will be trying is Signatures. But this will be a bit different from what I had thought. Earlier, from my readings I had thought to implement,

1. Keys

2. Signatures

3. Certificates, etc

But Martin has something in mind for password erasure from Memory{scratching surface of IO directly}, while handling Signatures, and other things{I guess, not clear of the plan}. So I have been having an overview of the I/O architecture in jruby now, to see how this will be done.

Next few days, it will be more refactoring and more of reading{which is what I spent most of my time till now.} So really, we don’t know what the plan is gonna be next, cause Martin has his own ride, which is touching many more features{which I dint have in mind before.}

I don’t know what the next few days will bring in.

GSoC 2012

GSoC 2012 Logo

Hello, World!

I was selected this year to be a part of JRuby, and contribute as part of Google Summer of Code 2012.

Over the summer, I will try to add features to krypt and hopefully digital signature support, with an exited mentor Martin Bosslet. He’s over from Germany and is pretty much interested in security.

The deal is open-ended with me trying to complete as many features for Digital Signatures and then move on for more powerful features, with the likes of touching nokogiri{xml},  and pdf support. If possible try on an adventure with Martin’s idea of Signing Ruby gems .Whoa, thats a hell lot!

Over the short period of three months, which overlap my exams, I will try to implement as much possible to make most of GSoC. Currently I am undergoing the Community bonding period, where I am getting to know more about krypt, JCE, Digital Signatures, etc. As a start I tried porting RIPEMD-160 , and did other tests, to get me going.

This is going to be a super awesome summer!

GSoC Selected Meme

After a long time

This is a long pending post for so many things that have happened over a long time. I couldn’t post due to  so much of frenzy going around.

To start off, I conducted around 3 workshops and talks,

First one was a workshop for the Faculty of University of Pune, which was conducted at PVG College, Pune. It was aimed at giving a brief idea of how OpenStack works and Eucalyptus along with it.

I then went on to demo Cloud setup over Openstack.

Slides @ http://vipul.byclor.org/slides/presentation.html

Second was a workshop on Android for a state level student workshop which was conducted for around 150 students from 28 colleges of Maharashtra. It was held at ADCET College Ashta {http://www.adcet.org.in/}.

This one was special for me, as I received a splendid response from the participants. It was awesome!

You can find demoes from the workshop over at https://github.com/vipulnsward/AndroidWorkshop

Then came a brief Lightening talk over Git and Ruby and Cloud, at the RubyConfIndia 2012.{rubyconfindia.org}

Slides @https://github.com/vipulnsward/RubyLighteningTalk

I then happen to have conducted a workshop on Blender at SKNCoE {skncoe.edu.in} which was one whole day thing, and then the same at PICT{My College| pict.edu}.

Well thats all about for now. There have been many exiting projects I have been working over, which I will be posting soon. But you can find many @github.com/vipulnsward

Week one :grit

We tried to read and understand parts of grit
RDoc can be found here: grit.rubyforge.org

As it seems, its doesn’t encompass all of git’s functionality, but is infact just a wrapper over git
What it essentially does is, give us a OO wrapper over all Git’s objects,and access to change or retrieve data from them, which
is what was desired in the first place

So to move forward, we came up with two ways
1. Create a solution on top of grit { Useful and easy for now, also makes sense to not disturb what grit does}
2. Create an integrated solution as part of grit {would be useful later}

We are going ahead with [1]

Examples for creating a commit
=====================
require ‘../lib/grit’

count = 1
Dir.chdir(“/home/sward/project/testrepo”) do
r = Grit::Repo.new(‘.’)
while(count < 1) do
fname = Time.now.to_i.to_s + count.to_s
File.open(fname, 'w') { |f| f.write('hellor ' + fname) }
r.add(fname)
count += 1
end

r.commit_index('my commit')

end

======
To read data and other info we would just need the handle to Repo object, which encompasses
all of git's other objects which are essentially these

=====

From rubyforge you can find important objects we are interested, some being Commit, Merge, Repo, Git, etc

But for us to torrent we are interested in Blob object which contains dumps of data from file and doesnt always match
the data to a unique file, meaning if there were to be two files with same data,only a single blob would be created as the
hash of both would be same.

blob gives us data that we could piece and then torrent, as with the state of the git database, we are yet to confirm how to approach that as well.

[1] Send out a pretty good hash containing all of gits object we may read from grit
[2] Send the .git repo's files we are interested in wrapped together.

[2] one being more easy but [1] being logical for us to do now.

Along the same time, I happened to look over at ruby-torrent

Previously we were under the impression that this would host a tracker solution as well. It appears its just a client in ruby. Similarly librubytorrent also doesnt help in case of a tracker.

There were other project attempting this, which were but Rails and sinatra
[1] https://github.com/shurikk/bttrack
[2] http://code.google.com/p/hydraproject/

This one was of particular interest
https://github.com/shaggyone/ruby-tracker

So we will be going ahead with the last solution and start studying is this week.