A.8 Connecting to the iSCSI Target Virtual Machine via SSH

To manage the newly created virtual machine, connect to the server via SSH from the local computer where you downloaded the xxxkey.pem file. In the initial SSH session, you connect as the root user. Later, you can create other identities on the server for administration purposes and log in to the session with a different user name.

A.8.1 Getting the SSH Syntax Information

The syntax to use for your SSH connection is provided by the Instances option in the Amazon Web Services console.

  1. Continuing in the Amazon Web Services console, in the left pane under Instances, click Instances, then select the check box next to the openSUSE Linux VM (the currently running AMI instance).

  2. From the Instance Actions drop-down menu, select Connect.

    The pop-up dialog box provides the syntax information you need to connect via SSH to your virtual machine.

    The general syntax to SSH is:

    ssh -i xxxkey.pem root@ec2-xxx-xxx-xxx-xxx-xx.xxxxxx-x.amazonaws.com
    
  3. Use one of the following methods to connect via SSH to the virtual machine:

A.8.2 Using SSH on Windows

When you work with the key file (xxxkey.pem) on a Windows machine, you need to convert the key to use a file format that is compatible with the SSH connection method you plan to use.

This section describes how to use PuTTY software for the SSH connection. PuTTY cannot directly open PEM key files. You must convert the key file to PPK format. The setup is a one-time process. After you set up an SSH session in PuTTY, you can easily connect to the VM at any time.

Downloading the PuTTY Software

  1. In a Web browser, go to the PuTTY Download page.

  2. Download the following software to your Windows machine:

    Software

    File Name

    Description

    PuTTY

    putty.exe

    A Telnet and SSH client

    PuTTYgen

    puttygen.exe

    An RSA and DSA key generation utility

    Pageant

    pageant.exe

    An SSH authentication agent for PuTTY

  3. Continue with Converting the PEM Key File to PPK Format.

Converting the PEM Key File to PPK Format

  1. Launch the PuTTYgen software by double-clicking the puttygen.exe file, or by right-clicking the file and selecting Run as administrator.

  2. In the PuTTY Key Generator window, click Load, then select the xxxkey.pem file that you downloaded to your local computer in Section A.3, Already Have an Existing Amazon EC2 Account?.

  3. After the key information is loaded, specify a key comment and passphrase.

    The Key passphrase and Confirm passphrase fields allow you to choose a passphrase for your key that is used to encrypt the key on the disk. Use a strong passphrase for a more secure solution. Do not forget your passphrase. There is no way to recover it.

    You must enter the passphrase when you use the key to connect via SSH to the virtual server. To avoid entering the passphrase each time you start an SSH session, you can set up the key and passphrase in Pageant, as described in Setting Up the Key File and Passphrase in the Pageant Authentication Agent.

  4. Save the private key in .ppk format.

    The converted key is saved as xxxkey.ppk. Ensure that you store the xxxkey.pem and xxxkey.ppk key files in a secure location on your local computer.

  5. Continue with Setting Up the Key File and Passphrase in the Pageant Authentication Agent.

Setting Up the Key File and Passphrase in the Pageant Authentication Agent

Pageant is an SSH authentication agent. It holds an authentication key in memory, already decoded, so that you can start SSH sessions often, without needing to type a passphrase each time. PuTTY automatically retrieves the decoded key from Pageant when you start your SSH session with the virtual machine. When you stop the Pageant from running, the decoded key is removed from memory.

  1. Launch the Pageant software by double-clicking the pageant.exe file, or by right-clicking the file and selecting Run as administrator.

    The Pageant authentication agent starts running and places an icon in the notification area.

  2. In the notification area, right-click the Pageant PuTTY authentication agent icon, then select Add Key.

  3. In the Select Private Key File dialog box, browse to locate and select the xxxkey.ppk file you created in Converting the PEM Key File to PPK Format, then click Open.

  4. When you are prompted, specify the passphrase for the xxxkey.ppk file.

    The key appears in the Pageant Key List.

    The Pageant authentication agent must be running when you connect to the virtual machine with a PuTTY SSH session in order for Pageant to provide decoded key information.

  5. Continue with Configuring an SSH Session in PuTTY.

Configuring an SSH Session in PuTTY

  1. Launch the PuTTY software by right-clicking the putty.exe file, then selecting Run as Administrator.

  2. In the left pane, select Session.

  3. In Host Name (or IP address), specify the Elastic IP address that you set up for the virtual machine.

    You can alternately use the public DNS name of the virtual machine. You can find the DNS name by looking at the virtual machine instance in the Amazon AWS Management Console.

  4. In Protocol, select SSH.

  5. Set up the authentication settings:

    1. In the left pane, select Connection > SSH.

    2. In the left pane, select Connection > SSH > Auth.

    3. Under Authentication methods, select Attempt authentication using Pageant. This is selected by default.

    4. In Private key file for authentication, browse to locate and select the xxxkey.ppk file you converted in Converting the PEM Key File to PPK Format, then click Open.

  6. In the left pane, select Session.

  7. Under Saved Sessions, specify a name for this connection (such as iSCSI_Target_VM), then click Save.

    The name appears in the list under Saved Sessions.

  8. Close PuTTY.

    The PuTTY SSH session setup is complete. You can use PuTTY to connect to the virtual machine with your saved SSH session at any time.

  9. Continue with Connecting via SSH with PuTTY.

Connecting via SSH with PuTTY

After you have set up the SSH session in PuTTY, you can use PuTTY to run the authenticated SSH session at any time.

  1. Launch the PuTTY software by double-clicking the putty.exe file, or by right-clicking the file, then selecting Run as Administrator.

  2. In the PuTTY window, double-click the saved SSH session for the virtual machine, or select the session and click Open.

    If you are not running Pageant, you are prompted for the passphrase for the authentication key. Provide the passphrase to continue.

    A Login dialog box pops up for your OpenSSH session.

  3. When you are prompted, log in as the root user.

    After you are successfully connected, you are presented with a terminal console prompt for the virtual machine.

  4. Continue with Section A.9, Installing the iSCSI Target Software on the openSUSE Linux VM.

A.8.3 Using SSH on Linux

  1. On the local machine, open a terminal console, then log in as the root user.

  2. Go to the folder where you saved the xxxkey.pem file. At the terminal console prompt, enter

    cd /path_to_key_file_folder
    
  3. Connect via SSH to the virtual machine.

    The general syntax to SSH is:

    ssh -i xxxkey.pem root@ec2-xxx-xxx-xxx-xxx-xx.xxxxxx-x.amazonaws.com
    
  4. Click Yes to connect to the virtual machine.

  5. Keep the console open and do not terminate the SSH session.

  6. Continue with Section A.9, Installing the iSCSI Target Software on the openSUSE Linux VM.