ssh Archive

What is Shellshock?

What is the Shellshock Bash Vulnerability?

Shellshock is a recently discovered vulnerability that allows attackers to execute code on a system and set environment variables. The variables could be used to execute other more powerful commands.

What is Bash?

Bash stands for Bourne Again Shell. Bash was first released in 1989, the bug was introduced in version 1.14 and has been in place till version 4.3. This makes the vulnerability over 20 years old.

How do I know if my system is vulnerable to Shellshock?

To verify if your system is vulnerable, first you need to be running Bash. If you have Bash installed, executing the following command will output if you are vulnerable or not.

If your system is vulnerable the following result will be displayed on your screen:

If you got the message displayed above you will need to update your Bash installation.

If your system is not vulnerable to Shellshock then the following will be output to your screen:

How to patch my machines against Shellshock?

Patching against Shellshock is as easy as updating Bash on the machine. Below are the commands for updating the various Linux operating systems:

Centos, Fedora, or Red Hat

 Debian or Ubuntu


Using Custom Vagrant SSH Public/Private Keys

Sometimes for a Vagrant box you want to use your own public SSH key instead of the public one provided by Vagrant by default. Either you want to securely share the box or you are paranoid about security. Whatever the reason may be, you can setup a custom generated public key.

What you need to get started:

This tutorial assumes that you have the following:

  1. A working Vagrant box
  2. A public and private key combination

Copy the public key:

In order to use your custom generated public key we will need to copy it to the vagrant user’s authorized_keys file.

Assuming that you have your vagrant box running on localhost and port 2222. Then your public key has now been copied over to the vagrant user.

Modify the Vagrantfile

We need to tell Vagrant that we are using our own public key instead of the usual supplied one. To do this we need to modify the Vagrantfile. Open the Vagrantfile for your Vagrant box in your favorite editor and add the following config parameter:

The above config parameter is telling Vagrant to use your private key instead of the default one provided by Vagrant. You will want to give it the location of the private key you want to use.

Test the changes

You need to reboot your Vagrant box for the settings to take effect. Once the box is up try and SSH into the box. If you followed all the steps you can now try to SSH into your Vagrant box:


SSH Public Key Authentication

Public key authentication is not only more convenient than entering a password but also far more secure. On any given day your server or machine if SSH is on default port 22 and you have a public IP, it will probably receive at least 1,000 login attempts. These are all automated processes created in order to gain access to a server. They are not after your server, but they are after any server they can get their hands on.

When you generate a public key you are creating a random encrypted password, which is not easily hacked and tied to your particular machine. Only the machine that has the matching private key will be able to gain access.

The steps for generating a public key are rather simple. First generate a private and public key on the local machine, then copy the public key to the host. It’s that simple, but let’s go through all the steps:

1. Generate the public key

Make sure you are logged as the user you want to generate a public key for. To generate the public and private key we are going to use the ssh-keygen command.

If you notice I passed the argument -t rsa this specifies that I want to use the rsa protocol for generating the key. I also did not enter a password. You may enter a password if you wish. It would defeat the purpose of password less authentication but it will make login more secure.

If you look at your home directory, there is now a .ssh folder. This contains your private and public key.

id_rsa is your private key and your public key.

2. Prepare your host to receive the public key

To copy your public key to your host you need access to it. So of course you need to have a password.

In order to copy over the public key we need to create the .ssh folder on your host. Login as your user and in your home directory create a .ssh folder and chmod it to 700.

We also need to create the authorized_keys file, this is where we will copy out public key into. This file contains all of the public keys that are authorized to login to this machine.

3. Copy the public key to your host

Go back to your machine and make sure you are logged in as the user you generated the public and private keys for.

Type in the following to copy over your public key. Replace YOUR_USERNAME with your user and YOUR_HOSTNAME_OR_IP with your host’s hostname or ip. The command will ask you for your password since you haven’t yet added the public key to the host.

Your public key is now setup on your host. You can now ssh into your host without the need of a password:

4. Optional – Delete your password from the host machine

If you want to be really secure, you can delete your password from the host. This will ensure that only the machine with the private key will have access to this user. Note, that if you ever lose the private key you will lose access to the host.