Converting a putty ppk file to a pem file for accessing AWS ec2 instances

A few weeks ago I was working on a project in which the existing developers had setup access to their AWS EC2 instances using putty as their ssh client due to them running on Windows 7. They provided the putty private key file they setup but that didn’t do me any good because I was running OS X. Here is a list of steps I took to convert that PPK file to a PEM file that I could use to SSH into any EC2 instance.

  • To start you will need either macports or homebrew.
  • if using macports you will run the following command to install putty for mac:
  • if you are using homebrew you will run the following command to install putty:
  • The remaining commands will be the same when using macports or homebrew. To generate the pem file run the following command:
    Keep in mind that you will want to substitute the name of your ppk file in place of the privatekey.ppk name I used. You will also want to change the name of the pem file you want to create rather than using privatekey.pem, unless of course you want to use privatekey.pem.
  • Next you should place the privatekey.pem file in your ~/.ssh directory
  • Now, lets set the pem file to have the proper permissions:

That’s it. You now have a valid pem file that you can use to connect to your EC2 instances from your Mac. Below is an example of the command you can now run to connect to your instances:

That’s it for this post, hope this helps someone out in the future. And by someone I most likely mean future me!

Posted in AWS Tagged with: , , , ,

Resources for learning Rubymotion

Here is a short post on some resources you can use to get started using RubyMotion. If you are a Ruby developer and know nothing about iOS development, but want to develop an iOS app then I highly recommend you get a subscription to RubyMotion and utilize some of the following resources to get started. You don’t need to know objective-c to get started although it will help you to understand the syntax as most code examples you will find on sites like Stackoverflow will be in objective-c. It’s quite easy to convert the objective-c syntax to syntax that RubyMotion understands so spending some time to learn the objective-c syntax will be worth it.

To get started I would recommend the following free tutorial by Clay Allsopp

The best resource, in my opinion, to learn RubyMotion would be to purchase the RubyMotion: iOS Development with Ruby book also by Clay Allsopp. The book can be purchased at PragProg.

Another great book you should consider purchasing is called RubyMotion iOS Development Essentials by Abhishek Nalwaya. The book can be purchased here. While some of the content in this book is the same as the RubyMotion: iOS Development with Ruby book there are plenty of new topics in this book and it does provide some better examples in my opinion.

If you are a visual learner, which most of us are, I would recommend checking out the video tutorials over at

Finally, once you are up and running with RubyMotion. You will want to head over to and explore all the wrappers that are available to make development even easier and quicker than it already is with RubyMotion. Some of the must have wrappers that I recommend using in every project would be BubbleWrap and Sugarcube.

That’s it for now and good luck in your iOS development with RubyMotion.

If you don’t have the time to learn RubyMotion or objective-c to create your own apps feel free to contact Facet Digital and we’d be happy to discuss your needs and build an app for you.

Posted in Ruby Tagged with:

Memory Mapped Files with C#

Today I’m going to talk about Memory Mapped Files in C#. A memory-mapped file contains the contents of a file in virtual memory. This mapping between a file and memory space enables an application, including multiple processes, to modify the file by reading and writing directly to memory. Starting with the .NET 4 framework you are now able to use managed code to access memory-mapped files the same way Windows does. Why is this important? If you need to process large files, using memory-mapped files can be a lifesaver. Memory-mapped files will allow you to access the contents of a file without running into out of memory exceptions, gain quick access to the content within the file, and even allow multiple processes and threads to process the content in parallel. You can read up more on memory-mapped files on msdn.

One thing that is important to note about using a memory-mapped file is that you need to know the starting byte and ending byte of the content you want to work with. To be able to work with the content for a large file it’s best to index the content first before doing any processing of that content. Unless of course you are working with an image file or another file that doesn’t require you to know the exact positions of the content you are trying to access within the file. You might be thinking that indexing the file first would make things slower but in fact it usually takes milliseconds to index content, even in gigabyte files. Once the indexes are created, we are then able to go directly to the content within the large file using the indexes we created. Here is a basic example on how to open a file for reading using a memory-mapped file:

I’ve used a using statement to ensure that the dispose method is called even if an exception occurs when we are working with the memory-mapped file. You don’t have to use a using statement but you better make sure you properly dispose of the memory-mapped file object otherwise you could bring your program to a crashing halt.

Now that we have the file open, we need to create either a view stream, used when you want to work with non-persisted memory-mapped files, or a view accessor which is used when you want to work with persisted memory-mapped files. The difference between persisted and non-persisted is based on wether or not you want to work with the content in memory or on disk. In this example I’m going to go the non-persisted route and work with the content in memory. I would recommend that if you are working with files in the gigabyte size range that you do not use the non-persisted method.

Here is an example method containing logic that is needed to actually get content from the open memory-mapped file:

The key items to focus on are the parameters to the method. The first is a reference to the memory-mapped file, the second is the beginning byte location of the content we want to access within the file and the last is the length of the content. If you remember back to when I said we needed to index the content first before we could work with the file, this is exactly why we needed to do that indexing. In order to get the content from the file, you need to know the starting byte location of the content you want to get as well as how much of the content thereafter you want to get. Because we are working in the binary world when we use memory-mapped files we need to convert the content we retrieved from a byte array to a string so that we can work with the content like it is originally presented in the file we are processing.

Now that we have the content, we can do whatever we want with it. This is where the real power of using memory-mapped files comes into play. For example, you can create parallel logic to retrieve the content from the original file thus allowing you to process that content very quickly and dramatically increasing the performance of your processing capabilities. Here is a brief example of some parallel logic:

Obviously the code shown above were just examples but hopefully you get the idea of the power that memory-mapped files can provide when you need to work with large files. If you need to work with processing the contents of documents, images or any other type of large files I would highly recommend you look into using memory-mapped files.

Posted in C# Tagged with: ,