IMPORT YOUR OWN RSA SSH KEY INTO AMAZON EC2

Recently, I needed to import my own RSA SSH key to EC2. Here is a quick way to import to all regions

NB: You need the ec2 tools set up before you can run this. You will also need to have setup an x509 certificate pair.

You can read more about the ec2-import-keypair command in the EC2 documentation.

Foreign Key MySQL Tutorial

Creating a foreign key in MySQL is a part of referential integrity in the database. A foreign key connects to tables. A foreign key is used in conjunction with a primary key, which is the main record for the dataset. For instance, a primary key could be used on a customer’s table. The customer ID is a unique field that distinctly identifies the customer. A foreign key is placed on the orders table, which connects the customer to his order.

Primary Key
Before creating a foreign key, a table that holds a primary key field needs to be created for referential integrity. In this example, creating the table for customers and orders can be accomplished using the MySQL command line. The syntax for creating a table is below:

In this example, a table is created using the “create table” keyword statement. If a primary key is undetermined, the programmer can leave out the primary key statement until he knows on which field to place the key. However, it’s important for tables to contain a primary key, because these elements speed up performance. In this example, a primary key is created on the “CustId” field. The CustId is used to distinctly identify the customer. Additionally, when assigning a primary key to a table, it must be unique.

Foreign Key
Now that the primary key is created, a foreign key is created on the orders table. Again, if the database developer is unsure of the foreign key to use at the time of table creation, it can be added later. The following code creates an orders table with a foreign key that points to the customers table:

Notice that a primary key was created for this table as well using the OrderId, which is also a unique value. The statement that defines the foreign key is the last one in the table syntax. It defines the foreign key and tells the database where its primary key is located. In this example, the CustId field in the orders table references the CustId in the customers table.

Remotely Connect to Your EC2 Server Using Coda FTP

Getting Coda to Remotely Connect to Your EC2 Server

Okay, so let’s jump to it. How do you get Coda to connect to your EC2 server?

First thing you will need is your private key (the file that you should have received from Amazon that ends in PEM). If you don’t have one of these babies then you’re going to need to go through Amazon’s getting started guide paying specific attention to section 3 & 4 on the “Launch Instance” section and the “Connect to Linux/Unix/Windows Instance”.

For the purposes of this walk through we’ll assume that the name of your private key is: my_key.pem

Now that you have your key you will need to move it to your ssh directory. Opening up Terminal, go to your ssh directory by typing:

You may either choose to copy your key into this folder, or, you can leave your private key wherever it so provided you know the path to it. Copying the file to the ssh directory would require you to do this:

Once you have either copied your key or noted its exact location in the ssh directory that you are actively in edit the config

Even if you don’t have that file, by doing the above you will be creating it. You may also need to be super-user if no permission is given:

In this file add the following lines (instructions of each line are after the # mark so you may remove information after these):

To save this document in vim you will need to exit by hitting :wq and then hitenter to save the document.

When this done, if you private key hasn’t been added you should do that now by entering:

or

To test that there are no problems with connecting to your server, enter in terminal the next command:

(instead of root you may be asked to use ubuntu instead, i.e.

If you receive any

errors at the bottom of the text you will have to change the permission of your key file, to do this enter:

or

Then try running the previous command again.

If you find upon running the

that you are faced with a prompt that asks you a yes/no question, enter “yes”.

Once you have successfully gained access to your EC2 server from the terminal window you are now almost ready to interface your server with Coda!

Open up Coda, click on the Sites tab button, click Add Site…and in all the text-boxes add the appropriate information according to your settings from the image above. A little more detail is provided here:

  • Nickname: can be anything you want to help you identify the site in Coda.
  • Root URL: URL to access the site.
  • Local URL: local location of the site (I use MAMP to test my sites)
  • Remote Root: where the server files are located that are directly correlated to the local structure
  • Local Root: where the local file/folder structure can be found
  • Server: the “Host” name you inserted in the config file above, i.e. 1.2.3.4 (or the public DNS address)
  • User Name: either “root” or “ubuntu” or whatever the server requests as a user to log in to the server
  • Password: LEAVE BLANK!
  • Port: leave on the default 22
  • Protocal: SFTP

When all this has been done you can click on “Save”. When you’re sure that all the details match up correctly, click connect in the “Remote” tab area and hopefully everything should work as it should! If you do get password prompts check that your key file has been chmod to 600 (see above) and that your ~/.ssh directory has been chmod to 700.

If you still run into problems PLEASE check that all the server details and username details are correct. I had my server IP address round the wrong way and that threw out a few attempts.

Anyway, hopefully this helps you integrate Coda and your EC2 server together quicker.

PS: make sure your folder has permissions for the user you are uploading the data to, I had to run this command in terminal before it allowed me to upload files from within Coda: