1. Home
  2. Files
  3. How to Create an SSH Key and Connect to an Account Remotely

How to Create an SSH Key and Connect to an Account Remotely


The use of SSH keys is of utmost importance in regards to safety on the Web. They allow you to safely execute commands on a server remotely.

Before beginning this article, we will briefly explain the SSH protocol. Then, we will cover the section Files, SSH Connections in N0C, and explain how to create SSH to access the terminal and to do command lines remotely. We will conclude this article by explaining how to create an SSH key with various operating systems.

We will mainly cover information for intermediate users. However, remote command lines will be of more interest to advanced users.

Note: This article does not cover password login to the hosting account management platform. You should refer to your hosting provider’s documentation to find out how to obtain the detailed information for each hosting account.

Note :The Glossary contains explanations on multiple topics and can be consulted to clarify certain terms.


Access to https://mg.n0c.com/en/.

What is an SSH Key?

A Secure Shell key — usually called SSH key — allows you to create a secure connexion on a network that is not secure, such as the Internet.

An SSH key has two components:

  • A public key that is available for all (the client and the server). It is a cryptographic key that can be obtained and used by anyone to encrypt messages intended for a particular recipient. The server uses it for authentication.
  • A private key, that is kept secret, because it is known only by the client and is kept on their machine. The private key is used for deciphering messages with the corresponding public key.

Using an SSH key to create a connection between two computers offers the advantage that only the public key needs to be exchanged on the network. Since transmissions encrypted with a public key can  only be deciphered with the corresponding private key and a password, a pirate cannot do anything to decipher communications on the Web, as  they have no access to the private key.

Remote Connection via SSH (N0C GUI Mode)

You will need at least four  credentials to connect via SSH: the server address, the username, the password and the port.

If you intend to connect remotely to the console by securing your data with the SSH protocol and if the machine you are working on is equipped with OSX or Linux, this causes no difficulty: you have everything you need to start and use SSH from the terminal without any particular application.

However, if you work on other operating systems, such as Windows, some software manipulations need to be done. For Windows, you will have to install the third-party application PuTTY (it is the most popular and is recommended). Its downloading process will be explained.

Connect With SSH password to your Hosting Under Microsoft Windows Environment

Before downloading and installing PuTTY, you must get your username and password. To do so:

  1. Connect on your hoster’s website.
  2. Find the password of your domain.
  3. Copy your password in the clipboard.
  4. Download PuTTY from its official website. Click on the installation program (here, putty-64bit-0.74-installer.msi).
  5. Run PuTTY. Make sure that the SSH radio button is automatically activated under Connection type in PuTTY Configuration.
  6. Enter the IP address of your server or the hostname (for example, node2-ca.n0c.com).
  7. Enter the proper port. It depends on the type of hosting you have: unless otherwise specified, use 5022.
  8. To save the entered information, so that you don’t have to provide it again at each connection, name the session in the Saved Sessions field and click on the Save button.
  9. Launch the SSH session by clicking on the Open button. The first time, PuTTY should request a confirmation.
  10. As the server displays login as, identify yourself by entering your username and press the Enter key on your keyboard.
  11. Enter your password; as you have copied it at step 3, you can do a right click with your mouse (it is normal that no characters are displayed when typing the password).
  12. A message from the hosting server is then displayed, proving that you have successfully connected with your SSH key.
  13. Type logout to disconnect.

Connect with SSH Password to Your Hosting from the MacOSX Environment of Apple Computers

The program being native, you just have to activate it:

  1. Launch the terminal by opening Applications > Utilities > Terminal.
  2. Type the following command by replacing user with the username you intend to connect with, serverip with the IP address of the server to connect with, and port with the appropriate port.
ssh user@serverip -p port
  1. Press the Enter key on your keyboard to launch the SSH connection; enter the password (no character is displayed when it is typed) and press Enter once again.
  2. If it is your first connexion, the terminal will ask you if you can trust the remote host and if you intend to stock the rsa2 key in memory; you can then type yes on your keyboard.

Remote Connection to a Hosting with a Private SSH Key 

We have explained how to connect to your hosting via the SSH GUI. Now, we will explain how to establish such a connexion by generating an SSH key (public and private pair).

No matter the operating system, the steps are the same:

  1. Generate the keys.
  2. Send your public key to the remote server.
  3. Test the connection.

We will show the procedure for MS-Windows, Mac OS, Linux/Unix (Ubuntu, Fedora, CentOS, Debian, Deepin, etc.), Solaris, Free BSD and Chrome OS.

Remote connection with SSH key under MS-Windows

Step 1 – Create New Public and Private Keys

Even if many methods exist, we will explain only one using the PuTTYgen tool.

If PuTTYgen is not already installed:

  1. Install PuTTYgen here, and select puttygen.exe.
  2. In the PuTTY Key Generator interface,  make sure that the number of bits is at least 2048.
  3. Click on the Generate button and, as requested, move your mouse in the empty zone (this contributes to randomly generate the private key).
  4. Click on the Save private key button.
  5. Save the private key under the name id_rsa.ppk.
  6. Click on Save.
  7. The dialog box Key / Public key for pasting into OpenSSH authorized_keys file contains the public key that has been generated.

Step 2 – Copy the Public Key on the Remote Server

  1. Launch PuTTY and connect to the server with your existing user identification information, as previously explained in «Connect With SSH password to your Hosting Under Microsoft Windows Environment».
  2. In the PuTTY Key Generator interface, highlight the public key (starting with ssh-rsa) and copy the text (press CTRL + C on keyboard).
  3. In N0C, go to Files  > SSH Keys.
  4. Click on the Create button.
  5. Enter the name of the key in the TITLE field.
  6. Paste the copied PUBLIC KEY.
  7. Click on the CREATE button.
  8. Your key is then displayed in the SSH Keys window.
  9. Type logout to disconnect from the server.

Step 3 – Test Authentication with SSH Key

Close the PuTTYgen tool and open PuTTY again.

  1. In the PuTTY Configuration window, under Session, enter Host Name (or IP address).
  2. Go to Connection > SSH > Auth.
  3. Click on the Browse button under Authentication parameters / Private key file for authentication.
  4. Localize the id_rsa.ppk private key and click on the Open button.
  5. Finally, in PuTTY Configuration, click on the Open button again to connect remotely to the server  by authentication with both keys.
  6. You should then see the PuTTY screen with the connections to your domain.
  7. Type your username.
  8. Confirm that the authentication message with the public key is displayed.

Remote Connection with SSH Key Under Mac OS X

We will explain how to record an SSH key on a remote server in order to haveto type only SSH user@serverip -p 5022 without a password from Mac OS X.

Step 1 – Create New Public and Private Keys

  1. Enter in the terminal :
ssh-keygen -t rsa -b 2048
  1. The terminal displays:
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/johann/.ssh/id_rsa):
  1. Validate to keep the default directory (most simple approach).
  2. Do not enter anything when this message is displayed:
Enter passphrase (empty for no passphrase):
  1. Validate two times.
  2. The key is displayed.

Step 2 – Copy the Public Key on the Remote Server 

  1. Send your key to the remote server (in the distant user’s .ssh folder). Here is an example to adapt to your needs:
cat ~/.ssh/id_rsa.pub | ssh user@serverip -p 5022  "cat >> ~/.ssh/authorized_keys"
  1. The SSH password is then asked for the last time. Complete and validate.

Step 3 – Test the Authentication with the SSH Key

  1. Enter following text :
ssh user@serverip -p 5022
  1. If no password is requested, everything is functional.

Remote Connection with SSH Key Under Linux/Unix (Ubuntu, Fedora, CentOS, Debian, Deepin, etc.)

Before generating an SSH key, make sure that your machine is compatible with SSH connection.

Step 1 – Create the New Public and Private Keys

Follow the same approach as for MacOS X.

Step 2 – Copy the Public Key on the Remote Server

The next step consists of putting the public key in the distant server’s authorized_keys file.

  1. Type the following command, where serverip -p 5022 represents the IP address of your remote server and where user represents the name of the server user:
ssh-copy-id user@serverip -p 5022
  1. A similar warning message is then displayed:
The authenticity of host 'Server's IP address' can't be established. RSA key fingerprint is ... Are you sure you want to continue connecting (yes/no)?
  1. Type yes in the command line and press the Enter key. This message is then displayed:
Warning: Permanently added 'SERVER IP' (RSA) to the list of known hosts. user@serverip's password:
  1. Here, you have to enter the remote server user’s password (in most cases, the username is root).
  2. After having entered the password, another welcome message is displayed.
  3. Try to connect to the machine with « ssh user@serverip -p 5022 », and make sure that no additional key has been entered in ~/.ssh/authorized_keys*.

Step 3 – Test Authentication with SSH Key

  1. In this step, you have to connect to the server with this command:
ssh user@serverip -p 5022
  1. The new public key having been added to your distant server, each time you will connect to it, you will not be obliged to enter a password (unless you have configured a secret phrase for your RSA key).

Remote Connection with SSH Key Under Solaris

Refer to the article available at this link: https://docs.oracle.com/cd/E78370_01/html/E74671/generatesshkeys.html.

Remote Connection with SSH Key Under Free BSD

Refer to the article available at this link: https://docs.freebsd.org/en/books/handbook/security/#openssh.

Remote Connection with SSH Key Under ChromeOS

Refer to the articles available at the following links:

Updated on May 6, 2024

Related Articles