Use Key Ssh



Table of Contents

  1. Creating An Ssh Key
  2. Use Keys To Copy
  3. Use Ssh Key To Clone Git
  4. Use Keystrokes

SSH keys are typically configured in an authorizedkeys file in.ssh subdirectory in the user's home directory. Typically a system administrator would first create a key using ssh-keygen and then install it as an authorized key on a server using the ssh-copy-id tool. See also the dedicated page on configuring authorized keys for OpenSSH.

Use Key Ssh

Introduction

SSH can handle authentication using a traditional username and password combination or by using a public and private key pair. The SSH key pair establishes trust between the client and server, thereby removing the need for a password during authentication. While not required, the SSH private key can be encrypted with a passphrase for added security.

  • Select Use existing public key in the dropdown for SSH public key source so that you can use the public key you just generated. Take the public key and paste it into your VM setup, by copying the entire contents of the idrsa.pub in the SSH public key. You also want to allow your VM to accept inbound SSH traffic by selecting Allow selected.
  • Private keys allow the users to login to SSH without a password. This is considered a safe practice in some cases while also discards the need to remember multiple passwords.
Key

The PuTTY SSH client for Microsoft Windows does not share the same key format as the OpenSSH client. Therefore, it is necessary to create a new SSH public and private key using the PuTTYgen tool or convert an existing OpenSSH private key.

Requirements

  • PuTTY SSH client for Microsoft Windows
  • Remote server accessible over OpenSSH
Key

Install PuTTY and PuTTYgen

Both PuTTY and PuTTYgen are required to convert OpenSSH keys and to connect to the server over SSH. These two tools can be downloaded individually or, preferably, as a Windows installer from the PuTTY Download Page.

Once the PuTTY Windows installer is downloaded, double-click the executable in the Download folder and follow the installation wizard. The default settings are suitable for most installations. Both PuTTY and PuTTYgen should now be accessible from the Windows Programs list.

Use Existing Public and Private Keys

If you have an existing OpenSSH public and private key, copy the id_rsa key to your Windows desktop. This can be done by copying and pasting the contents of the file or using an SCP client such as PSCP which is supplied with the PuTTY install or FileZilla.

Next launch PuTTYgen from the Windows Programs list.

  1. Click Conversions from the PuTTY Key Generator menu and select Import key.
  2. Navigate to the OpenSSH private key and click Open.
  3. Under Actions / Save the generated key, select Save private key.
  4. Choose an optional passphrase to protect the private key.
  5. Save the private key to the desktop as id_rsa.ppk.

If the public key is already appended to the authorized_keys file on the remote SSH server, then proceed to Connect to Server with Private Key.

Otherwise, proceed to Copy Public Key to Server.

Create New Public and Private Keys

Launch PuTTYgen from the Windows Programs list and proceed with the following steps.

  1. Under Parameters, increase the Number of bits in a generated key: to a minimum value of 2048.
  2. Under Actions / Generate a public/private key pair, click Generate.
  3. You will be instructed to move the mouse cursor around within the PuTTY Key Generator window as a randomizer to generate the private key.
  4. Once the key information appears, click Save private key under Actions / Save the generated key.
  5. Save the private key to the desktop as id_rsa.ppk.
  6. The box under Key / Public key for pasting into OpenSSH authorized_keys file: contains the public key.

Copy Public Key to Server

Keys

The OpenSSH public key is located in the box under Key / Public key for pasting info OpenSSH authorized_keys file:. The public key begins with ssh-rsa followed by a string of characters.

Creating An Ssh Key

  1. Highlight entire public key within the PuTTY Key Generator and copy the text.
  2. Launch PuTTY and log into the remote server with your existing user credentials.
  3. Use your preferred text editor to create and/or open the authorized_keys file:

  4. Paste the public key into the authorized_keys file.

  5. Save the file and close the text editor.

  6. Adjust the permissions of the authorized_keys file so that the file does not allow group writable permissions.

  7. Logout of the remote server.

Connect to Server with Private Key

Use Keys To Copy

Now it is time to test SSH key authentication. The PuTTYgen tool can be closed and PuTTY launched again.

Use Ssh Key To Clone Git

  1. Enter the remote server Host Name or IP address under Session.
  2. Navigate to Connection > SSH > Auth.
  3. Click Browse... under Authentication parameters / Private key file for authentication.
  4. Locate the id_rsa.ppk private key and click Open.
  5. Finally, click Open again to log into the remote server with key pair authentication.

Use Keystrokes

SSH keys provide a simple and yet extremely secure way to connect to a remote computer or a server.
You can get $25 at UpCloud to test SSH features: https://upcloud.com/signup/?promo=alu25
In this video, you will learn:
0:41 Why use SSH keys
1:23 How to create SSH keys
2:14 What’s the difference between private and public keys
2:45 How to add SSH keys to a remote computer
5:18 How to disable password login and allow only the SSH key login
6:35 How to use SSH keys for password-less login
7:19 How to use SSH authentication agent and avoid typing you ssh key passphrase many times
The commands are available at https://averagelinuxuser.com/how-to-use-public-key-authentication/
How to Set up a Virtual Private Server https://youtu.be/KD6tR_0TozQ
How to install SSH keys https://youtu.be/47hjFcf8LKk
All Linux Server tutorials https://www.youtube.com/playlist?list=PLSmXPSsgkZLthWDi-saRez602Y8uixQBC
Tags: #SSH #UpCloud #AverageLinuxUser
################################################
Website: http://averagelinuxuser.com/
Facebook: https://www.facebook.com/AverageLinuxUser
Twitter: http://twitter.com/AVGLinuxUser