Introduction to SSH and SSH Keys

What is SSH?

SSH, or Secure Shell is an encrypted network protocol, to securely connect to another computer over a network. It can be used to execute commands on a remote machine, and also to copy or move files from one machine to another.

Using ssh on the command line

The command to connect to a remote machine is ssh. E.g.
$ ssh username@hostname

Copying files

Files can be copied using SCP (secure copy) e.g.
$ scp local_file username@hostname:destination_directory
or SFTP (SSH File Transfer Protocol).

SSH Keys

SSH Keys provide a more secure way to log in to a remote machine than using password authentication. To do this you create an SSH identity, which consists of a public-private key pair. A public key and a private key are generated on the client machine (e.g. your computer). Each key consists of a long string of characters, stored in a file such as id_rsa / You then copy the public key to the remote machine that you wish to log in to. When you connect to the remote machine, ssh uses the two keys to authenticate.

What is RSA?

You may notice the terms SSH Keys and RSA keys being used interchangeably. RSA is simply the name of an algorithm for encryption (named after Rivest-Shamir-Adleman). An alternative encryption algorithm is DSA (Digital Signature Algorithm), but that is no longer recommended.

How to generate and use SSH Keys

There are many good resources that explain how to generate and use SSH keys.
Here’s a couple of good explanations:
Digital Ocean – How to set up SSH Keys (easy to follow)
Ubuntu – SSH Keys (more detailed)

If you are connecting to a provided service they most likely have a specific guide. Eg.
GithubBitbucket, Amazon EC2 etc.

Further Reading

If you are interested in how the public and private keys work together, read about public-key cryptography.

Editing CodeIgniter websites (a speedy guide)

In this post I cover the scenario where you’ve been asked to work on a CodeIgniter website, and you’ve only got 10 minutes to find out how it works! I’ll be brief but I’ll cover

  • What is CodeIniter?
  • What is MVC?
  • CodeIgniter structure and where to find js, css and images
  • How to find the page you want to edit
  • Other possibilities
  • Where to go next

What is CodeIgniter?

CodeIgniter is a powerful, lightweight PHP MVC framework. It makes it quick and easy to build web sites and applications.

What is MVC?

MVC is a software architecture and stands for Model-View-Controller. It enables the separation of presentation code, logic and data.

Models – You want some data? The model deals with that.

Views – This is where you put your HTML and presentation code.

ControllersTell you where to go, talk to views and models, and are generally in charge of what happens.

CodeIgniter structure and where to find js, css and images

Javascript, CSS and images are often found in their own folders in the root directory. A stylesheet in a css folder like this can then be linked to with the code

<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/style.css" />

The very useful base_url() is set in application/config/config.php

The Models, Views and Controllers are found in




Here’s a possible folder structure.

codeigniter folder structure

NB. The application and system folders may have been renamed and moved (to enhance security). To find out where they are look in index.php for $system_path and $application_folder.

How to find the page you want to edit

CodeIngiter URLs are made up of segments, which tell you which Controller to look at. The Controller then tells you which view to look at. It works like this:

(or )

  1. controller segment tells you which controller to look at
  2. function segment tells you which function within that controller (optional)
  3. ID segment represents variables that are passed to the function (optional)

If there’s no function segment, look for the index function.

If there’s no controller segment, you need to find the default controller. Look in application/config/routes.php and find something like

$route['default_controller'] = "welcome";

This means that application/controllers/welcome.php is the default controller.

So, you’ve found the relevant function, now you need to find the view. Look for something like this:

$this->load->view('page1', $data);

This loads the view called page1. Look for application/views/page1.php. Et voila, here is the presentation code.

Other possibilities

If the site doesn’t conform to what I’ve described above, there may be some routing going on. See the CodeIgniter user guide on URI routing for more details on this.

Where to go next

One of the things I love about CodeIgniter is it’s really well documented and has a great community behind it. Check out the CodeIgniter User Guide.