3.3 Connecting to your virtual machine

3.3.1 Keypair based SSH connection

When your machine has a public IP assigned, you can open a terminal connection into your virtual machine. Any standard SSH client should work. More details about SSH based terminal connections are available in the terminal connections section of the CSC Computing environment user guide.

A new virtual machine will only have a default user account and the root or administrator account or in some cases only the root account. You can only log in using keypair based authentication:

ssh user-account-name@public-ip -i keyfile.pem

Where the user account name depends on the image. For images provided by CSC it is usually "cloud-user". With the default CSC images when you try logging in as root, you will get a message that tells you what username to use instead. Some third party images may use the root account directly.

You can also use an SSH agent instead of the command above. With an SSH agent, you will be able to have one machine with a public IP, and connect via SSH to the other machines from that machine, without having public IPs for all machines. To use an SSH agent in your local Linux or Mac OS X machine, start a shell and run commands:

ssh-agent /bin/bash
ssh-add ~/.ssh/keyname.pem

Now you should be able to connect using SSH to the public IP of your machine (visible in the web interface):

ssh -A user-account-name@public-ip

The difference is that you are no longer specifying the key to use using -i since this comes automatically from the agent. The -A option is for agent forwarding. It allows you to create an SSH connection from the virtual machine with the public IP to your other virtual machines without public IPs as long as they have the same key as the virtual machine with the public IP.

Before connecting to your virtual machine, you can check its status from the Instances view of the cPouta web interface.

Figure 3.5 Instances view of the cPouta web interface.

Figure 3.5 shows a sample of the Instances view. The view may look slightly different compared to the image due to changes in the look of the interface in newer versions of OpenStack, but for the purposes of this example the relevant information is still the sameIn this case we can see that virtual machine called a-dummy-instance is active and running. The machine has two IP addresses of which address is the public one. The machine uses a keypair called risto.

3.3.2 Getting root access on a virtual machine

If you logged in using a default user account, you will be able to run commands as root with sudo like so:

sudo <some command>

You can also get a root shell like so:

sudo -i

None of the accounts in the default images provided by CSC have passwords in them, and passwords are not necessary for using sudo. You can assume that the default user account has the same rights as the root user. If accounts that do not have root access are needed, those need to be created separately.

3.3.3 Connect to a machine using the cPouta virtual console

The web interface includes a console tool that you can use to login to your virtual machine directly. However, using the console requires you to create a user account with a password on the virtual machine.

You can open a console session by clicking Console from the instance dropdown menu:

To input text into the console click the grey bar as shown:

After this you can login with the user account and password you have created.

Previous chapter   One level up   Next chapter