Transferring files to an Amazon EC2 instance (setting up SFTP)

December 31, 2012

Just a quick tutorial on the basic steps to get SFTP set up and running on an Amazon EC2 instance. First you need to launch an instance. In this particular case I assume the use of the Amazon EC2 web interface and not the command line tools. If you wish to use the command tools then there are many good resources that can be found using Google.

Server Setup

Use the web interface to begin launching an instance. In this case I choose to launch a default Ubuntu 12.04 Server instance. The next few tabs are not particularly relevant – until we reach the create a key-pair tab. Give the key-pair a unique name and download and save it somewhere secure. Also make sure that the a security group that has Port 22 open.

If you are using Windows and putty you will need to convert the key-pair to an appropriate format. You can do this by downloading putty-gen and then load the generated key-pair using the File menu. You will need to switch the file type filter to All Files to be able to see the .pem file. You can then convert the file to a .ppk file for use with programs that use the Putty protocol.

WinSCP Setup

Assuming you were going to use WinSCP:

Add a new Host and set up the detail as follows (bold implies an explicit value and italics implies a value to be provided by you):

  • Host Name
    • EC2 Public DNS (eg. ec2-255-255-255-255.eu-west-1.compute.amazonaws.com)
  • User Name
    • ubuntu
  • Password
    • blank
  • Private Key File
    • The .ppk file we just generated  (eg. my_key.ppk)
  • Protocol
    • SFTP

Notice that this tutorial follows on from my previous tutorial on setting up FTP on an EC2 instance. As noted on this StackOverflow question it is much safer to use SFTP over FTP as your authentication details are not sent in plaintext.

1

Maven dependency for org.netbeans.* (AbsoluteLayout) in a Swing application

December 11, 2011

Just a quick post about how to resolve dependency errors in Netbeans when setting up Maven for a Swing application. I struggled to find any information on which repositories to use so thought I would post in case other people had the same issues as me.

If you create a Maven project and add existing Swing .java files then you may find errors such as:

Error package org.netbeans.lib.awtextra does not exist ...

This package resides in the AbsoluteLayout.jar that is normally automatically supplied by Netbeans. In order to add this dependency to your Maven pom.xml you need to add the following lines:

<repositories>
  <!--These are needed for Swing/Netbeans -->
  <repository>
    <id>maven2-repository.netbeans.maven2</id>
    <name>Netbeans Maven Repository</name>
    <url>http://bits.netbeans.org/maven2/</url>
    <layout>default</layout>
  </repository> 
</repositories>

This should be added somewhere above the opening tag.
Then add:

<dependency>
      <groupId>org.netbeans.external</groupId>
      <artifactId>AbsoluteLayout</artifactId>
      <version>RELEASE701</version>
</dependency>

You can check for the latest version of AbsoluteLayout.jar here.

1

Adding a Custom Configuration in CMake

September 20, 2011

To add a custom configuration to a CMake build (which only applies to multi-generators such as Visual Studio):

list(APPEND CMAKE_CONFIGURATION_TYPES DEBUGX64)
list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
 
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
    "Semicolon separated list of supported configuration types [Debug|Release|MinSizeRel|RelWithDebInfo|Debug-x64]"
    FORCE)
 
set(CMAKE_C_FLAGS_SUPERDUPER "-flagone -flagtwo" CACHE STRING
    "Flags used by the compiler during debugx64 builds")
set(CMAKE_CXX_FLAGS_SUPERDUPER "-flagone -flagtwo" CACHE STRING
    "Flags used by the compiler during debugx64 builds")
 
set(CMAKE_EXE_LINKER_FLAGS_SUPERDUPER "-flagone -flagtwo" CACHE STRING
    "Flags used by the linker for executables during debugx64 builds")
set(CMAKE_SHARED_LINKER_FLAGS_SUPERDUPER "-flagone -flagtwo" CACHE STRING
    "Flags used by the linker for shared libraries during debugx64 builds")
set(CMAKE_MODULE_LINKER_FLAGS_SUPERDUPER "-flagone -flagtwo" CACHE STRING
    "Flags used by the linker for loadable modules during debugx64 builds")
 
mark_as_advanced(CMAKE_C_FLAGS_DEBUGX64 CMAKE_CXX_FLAGS_DEBUGX64
                 CMAKE_EXE_LINKER_FLAGS_DEBUGX64 CMAKE_SHARED_LINKER_FLAGS_DEBUGX64 CMAKE_MODULE_LINKER_FLAGS_DEBUGX64)
1