Using a terminal emulator

This note is about using a terminal emulator from a Microsoft Wondows 10 personal computer to access the CLI on a eb server running Ubuntu or some other flavour of Unix or Gnu/Linux..

Table of contents

Introduction

To access the web server using the command-line interface (CLI) from a personal computer you use a terminal emulator.

You may use the MS WIndows 10 built-in ssh, Starnet's X-Win32 (commercial) or Simon Tatham's PuTTY (free software).

Logging in with a username and password

To log in on the remote with a username and password, use one of the following methods:

To use ssh, open up a Powershell window and just type the ssh-command.

For example, if your username is “bob” and the server you want to access is named “example.com”, do this from the PowerShell:

PS C:\> ssh bob@example.com

To use PuTTY you need to configure a session. The screen shot below is the PuTTY configuration screen. Make sure you set the connection type to “SSH”- The only other thing you need to fill in is the host name or IP-address to connect to.

putty_config.png
Configure PuTTY to connect over ssh.

X-Win32 If your computer is in a secure location (e.g. at home), you may store your login credentials in X-Win32 by means of X-Config:

xconfig.png
Using X-config do store login credentials.

Key based authentication

However, logging in on the remote with a password sent over the net is not recmmended. Best practice is to use key based authentication with various ssh clients.

Obtaining and installing keys

If you already have a working key pair, you should be able to reuse that.

If you don't, here sre links to how to generate a key pair on MS Windows and Unix:

After generating the pair, make sure the pair of key files are stored in a subdirectory named .ssh in your home directory. Check this before proceeding.

Copy the public key to the server and store it in the file ~/.ssh/authorized_keys. If you don't have access to the server, ask the server's administrator to do this for you.

To test that you have a working key pair, test it with the ssh client that is built into MS Windows 10.

For example, if your username is “bob” and the server you want to access is named “example.com”, do this from the PowerShell:

PS C:\> ssh bob@example.com

No mail.
Last login: Mon Apr  5 15:14:56 2021 from 192.0.2.0
$

This the dialogue shows a successful login using key based authentication.

However, you may want to use a more

PuTTY

If your key pair was generated by ssh-keygen, first convert private key file “id_rsa” to a PuTTY compatible file named “id_rsa.ppk”, using the following procedure:

  1. Open PuTTYgen (part of the PuTTY package).
  2. Navigate to Conversions » Import Key.
  3. Locate the file “id_rsa” on you computer (should be in ~/.ssh).
  4. Click on “Save Private Key” and “Yes” to save without a passphrase.
  5. Save it in the same directory, and name for new key file “id_rsa.ppk”.
  6. Close PuTTYgen.

Now open to PuTTY and add a path to key for the connection. Provided the username on the MS Windows PC and the remote server is the same, you can configure PuTTY to use the system username.

  1. Enter the remote server Host Name or IP address under Session.
  2. Navigate to Connection » SSH » Auth.
  3. Right of the “Private key file for authentication” field, click “Browse…”.
  4. Locate the private key id_rsa.ppk on your computer and and click “Open”.
  5. Navigate to Connection » Data.
  6. Select the radio button “Use system username (…)”
  7. Return to “Sessions” to save session configuration so you can reuse it later.
  8. Finally, click “Open” to log into the remote server with key pair authentication.

X-Win-32

Now go to X-Win-32 and add a path to key for the connection:

  1. Open X-Config
  2. Locate the connection to configure, and navigate to Edit » Advanced.
  3. Click on the … on the right of the “Key File” field.
  4. Locate the newly created “id_rsa.ppk” file and add it to the field.
  5. Click “Save” to save your yout connection with the private key.

Source: StarNet.com.

In some cases, PuTTY and pscp (the PuTTY version of scp is unable to locate id_rsa.ppk. You will typically get this fatal error:

FATAL ERROR: No supported authentication methods available (server sent: publickey)

A fix for this is to specify the full path to id_rsa.ppk on the command line:

pscp -scp -i C:\users\u\.ssh\id_rsa.ppk $file u@example.net:/home/u/sink

In PuTTY, create a session and add the full path by adding the full path to Connection » SSH » Auth in the field “Private key file for authenticton”, and the save the session.

Troubleshooting

Final word

[TBA]


Last update: 2021-07-06 [gh].