Browsed by
Month: February 2014

OpenSSH | Password-less remote login with private/public keys

OpenSSH | Password-less remote login with private/public keys

When accessing remote servers, you often do not want to type out your password ever time.  In order to avoid this you need to set up public and private keys.  These keys will authenticate you and will allow you to login to remote server with out the need to type in your password.

To get started, on your local machine run ssh-keygen command.  This command will generate your public and private key files.  It will first ask you for the location of where you want to save the key.  It will give you a default file name of ~/.ssh/id_rsa and this is the default file name that the ssh program will look at for a private key if none are specified as a command line argument.  Unless you only have one server to connect to, change this name to something else but keep the file inside of your ~/.ssh directory.  I usually choose the file name to be the name of the remote server.  So, for example if I am going to be creating keys for foo.com, I would start off by doing the following:

It will then ask you for a passphrase, just press enter and and then when it asks for the same passphrase again just press enter again.

It will then display some information on the screen and return you to your command prompt.

Now, if you look inside your ~/.ssh file you will see your public and private key, your public key ends in .pub.

Notice how the permissions on the files are set.  The private key foo is only readable and writable by you, however everyone can read your public key.

The next step is to transfer your public key to the remote sever, so for this example we want to transfer ~/.ssh/foo.pub to the foo.com remote server.

I simply use the scp command giving it the location of my local file and then the user@hostname:path.

In order for the remote server to know which keys are allowed, the public keys need to be placed in the file ~/.ssh/authorized_keys2, to do this we can run ssh and then give it a remote command to run.

The above command tells the ssh command to first login to the remote server and then cat out our public key and append it to the authorized_keys2 file.

After this, we should be all set. If you run into any issues with the authorized_keys2 file, check its permissions and  make sure that its only readable and writable by you and no one else.

Finally, to login to the server we run the same ssh command as before but we pass it out private key as a command line argument.

This can be made even simpler by creating a ~/.ssh/config file and specifying a server alias with a associated identity file (private key).  Take a look at my previous post to read about how to do that.

OpenSSH | custom configuration

OpenSSH | custom configuration

Every time you log into a server, you must specify your username and password.  If the server has a long hostname, this can be frustrating to type multiple times if you are logging into a server on multiple different windows.  In order to speed up this process, OpenSSH allows you to have a configuration script that you can set up to apply aliases to your login information.

For example, this is how the user foo could login to the server bar.com on the command line using ssh by typing everything out.

Instead of typing this out every time you can create a config file inside your .ssh directory in your home directory that will hold all of this information and give you a alias to use instead.

Read More Read More

VIM Text Editor | Custom configuration

VIM Text Editor | Custom configuration

There is a steep learning curve for editing text files with VIM or VI, but once you use it for a while it becomes second nature. In this article I will go over customizing VIM with a vimrc configuration file.

In order to customize VIM, you need to put your configuration details in a file called .vimrc under your home directory.

Read More Read More

Java | Install Oracle Java JRE on Ubuntu

Java | Install Oracle Java JRE on Ubuntu

Recently Ubuntu has stopped automagically install Oracle Java for you when the OS is installed. This is because in August 2011, Oracle removed the license that allowed Linux distributions to package Java for use in its repositories. Therefore, there are two options for users of Linux to install a Java JRE. The first option is to install OpenJDK through the package manager, which is a open-source implementation of the Java Platform. If you really need Oracle Java though to run a certain Java program, then the second option is to install the Oracle Java JRE manually. I will be going through the manual steps of downloading and installing Oracle Java in Ubuntu.

Read More Read More

x86 Bootloaders | Background

x86 Bootloaders | Background

It seems like magic that every time you press the power button on your computer, that everything just loads and works perfectly every time (well mostly every time). But what is actually happening under the hood that allows your computer to boot up into your operating system? I certainly do not pretend to know all the details, but I will describe what I do know at a high level and hopefully after reading this, the boot process will seem less magical and more of a logical step-by-step process.

Read More Read More

PIC microcontroller | Flashing LED

PIC microcontroller | Flashing LED

In this article I will look at flashing an LED on/off using a external clock delay. If you have not already read my previous articles, Pre-coding preparation and LED On, please do so now. Many of the concepts I have discussed in earlier articles will come into play in this project.

With this project, I will be using an external 20MHz clock instead of the built in 4MHz clock that comes with the PIC16F628A chip. To do this, I looked at the EasyPIC5 manual, to find out where to place and how to configure the board to register the external clock.

Read More Read More

PIC microcontroller | Turn LED on with PIC assembly

PIC microcontroller | Turn LED on with PIC assembly

This is a very good place to start if you are just starting out learning PIC assembly. If you have not yet read my Pre Coding Preparation article about setting up the IDE and testing your configuration, please do that before reading this article.

In this article I am going to describe how to turn on a LED in PIC assembly using the PIC16F628A microcontroller. To start off, open MPLAB IDE and create a new project using the Project Wizard. Then open your ASM file.

Read More Read More

PIC microcontroller | Pre-coding preparations

PIC microcontroller | Pre-coding preparations

In order to ease into the learning process of how to program a PIC microcontroller, I used a PIC development board which took care of hooking up all of the electronic peripherals to the microcontroller. The specific board that I am using is a EasyPIC5 Development System, by MikroElektronika. Below is the image of the board which has all the necessary peripherals for development and the microcontroller can be programed via USB 2.0. Click the image to zoom-in.

easypic5

Read More Read More

Linux Device Drivers | Concept character driver

Linux Device Drivers | Concept character driver

I have created this very simple character driver just to see how the process works from beginning to end when creating a device driver in Linux. Before we start, this driver is going to be compiled against the Linux 2.6 kernel and will probably not work in earlier versions. Also, make sure you have set up your development environment and that you have the Linux 2.6 kernel header files installed. If you need to review any of this, look back at the Pre-coding Preparation page.

The device driver that is described on this page is a very simple character driver which simply logs a message whenever a process tries to open/close the device file. I did this so that I could get familiar with the development process and understand how everything works together to create the driver. Eventually I am going to implement the open/read/write/close functions so that the driver will actually do something useful.

Read More Read More

Linux Device Drivers | Pre-coding preparations

Linux Device Drivers | Pre-coding preparations

A good place to start playing around with the Linux kernel and building device drivers, is inside a virtual machine (VM). I am running Windows on my desktop, but I use a VM to run different distributions of Linux. These VM’s are a good place to do development on because if you totally destroy the operating system, no harm is done to your host operating system (which is Windows in my case).

To create a VM, you first need a program that will run your VM’s. In my case, I will be using a program called VMware Player by VMware. This is a free program for Windows that allows you to run any kind of operating system inside a VM. The free version only allows you to run one VM at a time, while the paid versions allow you to run multiple VM’s at once. There are also many other programs available that will run VM’s, a popular open source one is VirtualBox by Oracle. VirtualBox is great because it will work on Windows/Mac/Linux and it will allow you to run multiple VM’s at once. It doesn’t really matter which one you choose, just make sure you pick one and download/install it.

Read More Read More