{"id":60445,"date":"2021-03-23T13:46:27","date_gmt":"2021-03-23T18:46:27","guid":{"rendered":"https:\/\/blog.cpanel.com\/?p=60445"},"modified":"2021-03-23T13:46:27","modified_gmt":"2021-03-23T18:46:27","slug":"how-to-use-putty-ssh-with-cpanel","status":"publish","type":"post","link":"https:\/\/devel.www.cpanel.net\/blog\/tips-and-tricks\/how-to-use-putty-ssh-with-cpanel\/","title":{"rendered":"How To Use PuTTY SSH With cPanel\u00ae<\/sup>"},"content":{"rendered":"\n

cPanel & WHM\u2019s intuitive web interfaces make it easy to manage servers and web hosting accounts. However, it\u2019s occasionally useful to work on a server\u2019s command line instead. The PuTTY SSH (Secure Shell) client allows you to log in to a server\u2019s command line interface shell over an encrypted connection so that sensitive data isn\u2019t exposed on the internet.<\/p>\n\n\n\n

Once logged in, you can access the full suite of Linux command-line tools, interact with the cPanel & WHM API utilities<\/a>, and create scripts that automate admin tasks. In this article, we\u2019ll show you how to log in via SSH with PuTTY SSH, including two ways to authenticate with the server: a username\/password combination and the more secure SSH keys.\u00a0<\/p>\n\n\n\n

What is the PuTTY SSH Client?<\/strong><\/h2>\n\n\n\n

The PuTTY SSH client is a collection of GUI tools for managing and interacting with SSH sessions. Its main components are an SSH session manager and a terminal emulator. It also includes a set of helper tools, including an SSH key generator, which we\u2019ll look at later in this article. <\/p>\n\n\n\n

PuTTY is compatible with several operating systems, although it is primarily used on Microsoft Windows\u00ae<\/sup> because, until recently, Windows did not have a built-in SSH client. <\/p>\n\n\n\n

Accessing cPanel Servers via SSH with PuTTY<\/strong><\/h2>\n\n\n\n

To follow the walkthrough in this article, you will need to install PuTTY<\/a> on your local computer. You also need access to a server or hosting account that allows SSH connections, as well as your cPanel account\u2019s username and password.\u00a0<\/p>\n\n\n\n

Logging in to your hosting account with a username and password is straightforward. Once PuTTY is installed, open it from the Start menu.\u00a0<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

The interface looks complicated, but at the moment we\u2019re only interested in the Hostname<\/em> and Port<\/em> fields. In Hostname<\/em>, enter your server\u2019s domain name or IP address. You can find the IP address in the General Information <\/em>section of the cPanel sidebar. <\/p>\n\n\n\n

Unless you or your hosting provider changed the server\u2019s SSH port<\/a>, leave the Port<\/em> entry on the default 22.\u00a0<\/p>\n\n\n\n

Click Open <\/em>at the bottom of the window and PuTTY will attempt to start an encrypted SSH session on your server. If this is the first time you\u2019ve connected, Windows may pop up a dialog asking for permission. You\u2019re safe to proceed if you entered the host details correctly. <\/p>\n\n\n\n

Once the connection is established, PuTTY opens its terminal emulator with a username prompt. Enter your cPanel username, press enter, and then provide your password.\u00a0<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

All being well, the server will authenticate you and you\u2019ll be given a command prompt. If you\u2019re happy to log in with your username and password, that\u2019s all you need to know to access cPanel via PuTTY.<\/p>\n\n\n\n

 Read on if you\u2019d like to learn a more secure way to authenticate. <\/p>\n\n\n\n

How To Connect to Your cPanel Server With PuTTY SSH and SSH Keys<\/strong><\/h2>\n\n\n\n

SSH keys are an authentication mechanism based on public-key cryptography<\/a>. The user generates a key pair with a public key and a private key. As the names suggest, you keep the private key secret and upload the public key to the server.\u00a0 The keys are mathematically intertwined so a cryptographic algorithm built into the SSH server can use the public key to verify ownership of the private key.\u00a0<\/p>\n\n\n\n

There are several benefits to this approach. SSH keys aren\u2019t vulnerable to brute-force and dictionary attacks; if you keep the private key secret, there is no chance of anyone guessing it. SSH keys can also use a passphrase so that they are even more secure. Unlike a password, the private key is never sent over the internet, so it can\u2019t be snatched as it traverses the network.<\/p>\n\n\n\n

SSH keys aren\u2019t perfect: if someone has access to the machine you store the private key on, they can steal it. But they are much more secure than the passwords people usually choose<\/a>.<\/p>\n\n\n\n

Generating SSH Keys with PuTTY<\/strong><\/h3>\n\n\n\n

When you installed PuTTY, you also installed the PuTTY Key Generator. Launch it from the Windows menu. It\u2019s another complicated-looking interface, but as before we\u2019re only interested in a couple of the features. <\/p>\n\n\n\n

If you want to use a passphrase with your keys\u2014and you should\u2014enter one in the Key passphrase <\/em>and Confirm passphrase <\/em>fields. <\/p>\n\n\n\n

Click the Generate <\/em>button and PuTTY will ask you to wiggle your mouse around. This seems peculiar, but the mouse\u2019s movement provides random data the software needs to generate keys. When you\u2019re done wiggling, the public key is displayed in the top text field.\u00a0<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

Before we get to the public key, click the Save Private Key <\/em>button to save the resulting .ppk file with a meaningful name. <\/p>\n\n\n\n

Uploading the Public Key to Your Server<\/strong><\/h3>\n\n\n\n

The public key must be made available to the SSH server, and we\u2019re going to do that by adding it to your user account\u2019s authorized_keys <\/em>file. <\/p>\n\n\n\n

Log in to your cPanel account and open the File Manager, <\/em>which you\u2019ll find in the Files <\/em>section of the main page menu. Browse to the .ssh <\/em>folder, select the authorized_keys <\/em>file, and click the Edit <\/em>button in the toolbar. <\/p>\n\n\n\n

Copy the public key from the PuTTY Key Generator and paste it at the bottom of this file; leave an empty line between existing keys and the new one. Click the Save Changes <\/em>button.<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

Both keys are where they need to be, so we can now use them to authenticate with the server. But first, we need to tell PuTTY where to find the private key.\u00a0<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

Open PuTTY\u2019s main session interface:<\/p>\n\n\n\n