This article describes how to create and deploy SSH keys using cPanel. With SSH keys, you can automate logins to your A2 Hosting account, or use two-factor authentication for increased security.
When you log in to your account interactively using an SSH client as described in this article, you must enter a password every time. But what if you want to run an automated process? Perhaps you want to automatically download a database backup at certain times to your local computer. In this scenario, you don't want to have to manually type your SSH password every time the backup process runs.
Or what if you want to allow multiple users to transfer files securely using SFTP, as described in this article? You would need to give them your cPanel password, which would give them complete access to your account.
You can solve these problems by using SSH keys to connect to your account. SSH keys enable your computer to log in to your A2 Hosting account automatically without you typing a password. To use SSH keys, you must first create a public key and private key (also known as a key pair). The client's private key stays on your local computer, while the public key resides on the A2 Hosting server.
Alternatively, you can also create SSH keys and protect them with a passphrase for two-factor authentication. Although this configuration does not enable automatic logins, it does provide an extra layer of security, because you must have the correct key file and know the correct passphrase to access the account.
When you configure SSH keys in cPanel, you can create a new key pair, or import an existing key.
To generate a new SSH key pair for your account, follow these steps:

If you are using the Paper Lantern theme, in the Security section, click SSH Access:
![]()
If you have already generated SSH keys for your account and want to re-use them, you can use cPanel to import them. To do this, follow these steps:

If you are using the Paper Lantern theme, in the Security section, click SSH Access:
![]()
In the Choose a name for this key (defaults to id_dsa) text box, type the name for the key.
Use the appropriate procedure below for your computer's operating system.
For computers running Microsoft Windows, you can use the PuTTY program to connect to your A2 Hosting account with SSH keys. Alternatively, Windows 10 includes a native SSH client that you can use, without the need to install and configure an additional program.
Before you can connect to your account, you must deploy the private key to your local computer (unless you imported a public key into cPanel, in which case you presumably already have the private key on your computer). To do this, follow these steps:

If you are using the Paper Lantern theme, in the Security section, click SSH Access:
![]()
At this point, you have created the SSH key pair and deployed the private key to your local computer. You are now ready to configure the PuTTY client to connect to your SSH account using the private key.
To configure PuTTY to use your private key, follow these steps:
To use the built-in Windows 10 SSH client to connect to your account using a key, follow these steps:

If you are using the Paper Lantern theme, in the Security section, click SSH Access:
![]()
Click , and then save the id_rsa file on your local computer. You are now ready to start the SSH client and use the key.
At the command prompt, type the following command. Replace username with your A2 Hosting username, and replace example.com with your site's domain name:
ssh -p 7822 username@example.com
If you did not save the key file in the \Users\username\.ssh directory in step 5, you must also specify the key file location. To do this, type the following command instead. Replace path with the path where you saved the key file in step 5:
ssh -p 7822 -i path username@example.com
If this is the first time you are connecting to the server, you receive a message about the key fingerprint. Type yes and then press Enter.
When you are connected, the remote server's command line prompt appears:
username@hostname [~]#
Before you can connect to your account, you must deploy the private key to your local computer (unless you imported a public key into cPanel, in which case you presumably already have the private key on your computer). To do this, follow these steps:

If you are using the Paper Lantern theme, in the Security section, click SSH Access:
![]()
At this point, you have created the SSH key pair and deployed the private key to your local computer. You are now ready to connect to your SSH account using the keys.
To connect to your SSH account using the keys, follow these steps:
ssh -p 7822 username@example.com
Host example Hostname example.com Port 7822 User usernameThe Host value can be any name you want; it is simply a label for the other settings. The Hostname value is the remote host you want to access, the port number is 7822, and the User value specifies your A2 Hosting account username. With this configuration defined, you can connect to the account by simply using the Host value. You do not have to type the port number, username, and hostname each time. The following command demonstrates how to do this:
ssh example
Host *
    AddKeysToAgent yes
	If you are using Mac OS X, add the following line as well:
	
    UseKeychain yes
	Alternatively, if you have an older version of OpenSSH installed on your computer, you can type the ssh-add command to manually store the passphrase in the SSH authentication agent for the duration of your login session.HostKeyAlgorithms +ssh-rsa,ssh-dss PubkeyAcceptedAlgorithms +ssh-rsa,ssh-dss
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.