cPanel File Management Hosting Tutorial

Now that you have your cPanel account, you will need to serve your web application or files to your visitors.

This hosting tutorial is about cPanel file management and how to serve that website content using either cPanel File Manager, SCP or SSH or via SFTP.

How To Use cPanel File Manager For File Management:

cPanel has an in-built file management system that is available at cPanel >> Home >> Files >> File Manager.

For users who are just getting used to cPanel, it is the easiest way to manage and edit your files.

The first thing you may want to do is to change the File Manger behavior when you log in.

To change the directory in which File Manager opens, perform the following steps:

  • Click Settings to open the Preferences window.
  • Select Web Root (public_html or www) for the most direct route to your files, or select another option to open the File Manager interface in that directory.
  • If you want to see your .htaccess file, just select “Show Hidden Files” and then click Save.

To create a new file or folder, perform the following steps:

  • Click + File or + Folder in the File Manager toolbar. A new window will appear.
  • Enter the new item’s name in the New File Name: or New Folder Name: text box.
  • Enter the location in which the system will save the item in the New file will be created in: or New folder will be created in: text box.
  • Click Create New File or Create New Folder.

To rename a folder or file, click the item’s name and enter the new name in the text box. Press the Return key to save the change.

To move a file into a folder, perform the following steps:

  • Click Move in the toolbar at the top of the interface. The New File window will appear. You can also drag a file icon into a new destination folder.
  • Enter the file path that you want to move the file to in the “Enter the file path that you want to move this file to” text box. You can also click an item and click Rename in the toolbar.
  • Click Move File(s) to move the file.

To move files into a folder, perform the following steps:

  • Select all of the items that you wish to move.
  • Click Move in the toolbar at the top of the interface. The New File window will appear.
  • Enter the file path that you want to move the file to in the Enter the file path that you want to move this file to text box area.
  • Click Move File(s) to move the files.

To copy a file, perform the following steps:

  • Select the file you want to copy. You cannot create a copy of an item within the same folder.
  • Click Copy from the toolbar at the top of the interface. The Copy window will appear.
  • In the Copy window, enter the file path for which you want to save the item.
  • Click Copy File(s) to copy the file.

To copy multiple files, perform the following steps:

  • Select the items that you wish to copy. You can also right-click and select Copy from the menu.
  • Select Copy from the toolbar. The Copy window will appear.
  • Enter the file path to which to copy the files in the “Enter the file path that you want to copy this file to” text box.
  • Click Copy File(s) to copy the files.

To modify a file or folder’s permissions, perform the following steps:

  • Select the file or folder for which to change the permissions.
  • From the toolbar, click Permissions. The Change Permissions window will appear.
  • Use the checkboxes or text boxes to change the item’s permissions. This setting’s permissions default to 0644 for files and 0755 for folders.
  • Click Change Permissions to save your changes.

To delete a file or folder, perform the following steps:

  • Select the file or folder you want to delete.
  • From the toolbar, click Delete. The Trash window will appear.
  • Click Trash File(s) to confirm that you want to delete the file or folder.

When you delete files or folders, the system does not permanently delete the files. Instead, the system moves the files to the Trash folder.
Click Empty Trash to permanently delete the Trash folder’s contents.

To restore a file or folder, perform the following steps:

  • Click View Trash from the toolbar.
  • Select the file or folder that you want to restore.
  • Click Restore in the toolbar.
  • Confirm that you want to restore the item.

When you edit a file with the Edit, Code Editor, or HTML Editor features, a window appears to confirm the file’s character encoding. Use the menu to select the correct character encoding for the file. Then, click Edit to continue.

Please note that if you select the wrong initial encoding, your file may become corrupt. If your file displays as a series of special characters, immediately abort the edit and select the correct encoding. Do not save the file.

In most cases, leave the feature alone or use it only when you know what you are doing.

To enable or disable the Character Encoding Verification Dialogs feature, perform the following steps:

Click Settings in the top-right corner of the interface. A new window will appear.

To enable encoding verification, deselect the Disable Character Encoding Verification Dialogs checkbox. To disable encoding verification, select the Disable Character Encoding Verification Dialogs checkbox.

Click Save.

How To Use SFTP CLI For cPanel Login & File Management:

You can also access your cPanel server and manage files using SFTP via the command line interface.

SFTP, which stands for SSH File Transfer Protocol, or Secure File Transfer Protocol, is a separate protocol packaged with SSH that works in a similar way over a secure connection. The advantage is the ability to leverage a secure connection to transfer files and traverse the filesystem on both the local and remote system.

Compared to the SCP protocol, which only allows file transfers, the SFTP protocol allows for a range of operations on remote files which make it more like a remote file system protocol. An SFTP client’s extra capabilities include resuming interrupted transfers, directory listings, and remote file removal.

Although passwords are easy to use, we do not set this up as part of our security measure.

Therefore we recommend you create SSH keys and transfer your public key to any system that you need to access.

This is much more secure and can save you time in the long run.

If you can connect to the machine using SSH, then you have completed all of the necessary requirements necessary to use SFTP to manage files.

Test SSH access with the following command:

$ ssh username@erver_ip_or_remote_hostname

If that works, exit back out by typing:

exit

Now establish an SSH connection and then open up an SFTP session using that connection by issuing the following command:

$ sftp username@server_ip_or_remote_hostname

If you are working on a server with a custom SSH port (not the default port 22), then you can open an SFTP session as follows:

$ sftp -oPort=$custom_port username@server_ip_or_remote_hostname

For more info on this, use:

$ man sftp
$ info sftp

How To Use SFTP Client For cPanel Login & File Management:

First, ensure that you have installed an FTP client on your local machine before you download and run the script file.

For instructions, visit the FileZilla™ (http://filezilla-project.org/) or Core FTP (http://www.coreftp.com/) websites for Windows® computers, or the Cyberduck (http://cyberduck.ch/) website or Panic Transmit (https://panic.com/transmit/) for MacOS® computers.

You can also see more at Wikipedia’s Comparison of FTP client software

If you encounter problems when you try to automatically configure your FTP client, ensure that your client is properly installed on your computer.

If problems persist, consult the FTP client’s documentation.

To configure an FTP client, perform the following steps:

  • Click Configure FTP Client for the desired FTP account.
  • Click FTP Configuration File under the desired FTP client’s logo. You can choose between Filezilla™, Core FTP, or Cyberduck.

Notes: cPanel only support auto-configuration for these FTP clients. To use another client, manually configure the client. Click Instructions to view detailed instructions for your chosen client.

  • Open the configuration script file that downloaded to your computer. The FTP client automatically opens, configures itself, and connects to your FTP server.

Panic Transmit:

Transmit is considered as the gold standard of macOS file transfer apps.

You need to have Transmit installed before continuing.

With it, you can upload, download, and manage files on tons of servers with an easy, familiar, and powerful UI.

Not only can you connect to your cPanel server via FTP, SFTP, WebDAV with ease, but it also allows you to connects to over cloud services, like S3, Backblaze B2, Box, Google Drive, Dropbox, Microsoft Azure, and others.

You can either download the 7 days trial from https://panic.com/transmit/ that enables you to use it as much as you want, without restriction, until the subscription kicks in or subscribe via Mac App Store for $24.99 USD/year.

However, the Mac App Store version:

  • does not support Transmit Disk (but we hope to restore Transmit Disk support in the future)
  • does not include the Open In Terminal feature (which was removed at Apple’s request)
  • has minor sandboxing-related limitations
  • no longer functions if your subscription expires
  • is only supported on macOS 10.14 (Mojave) or later

The drawback when downloaded from Panic.com is that if they ever release an all-new major update (like a “6.0”), there would likely be an upgrade price involved.

Before proceeding, ensure that you have generated the local machine keys and added them to your cPanel server.


The reason is that we do not allow password authentication because passwords are inherently bad and notoriously hard to remember, yet easy for attackers to break.

A secure password is a long, meaningless string containing a mix of letters, numbers, and symbols. Because they’re so hard to remember, it’s tempting to use the same password everywhere, which means you have to change all your passwords if just one login gets compromised.

So instead of a password, you have a pair of matched keys: one public, and one private. Anyone with access to the public key can use it to encrypt information, which can only be decrypted using the corresponding private key.

If you’re on a Mac, we can generate your keypair from the command line. Open a Terminal window and enter the following command:

$ ssh-keygen -t rsa -b 4096

Hit Return to create a keypair using the default name id_rsa and put it in the .ssh folder in your home folder.

Next you can opt to encrypt your private key with a passphrase.

The passphrase is an extra layer of security on your private key. With a passphrase, not only does someone need to gain access to your private key, they also need your passphrase in order to make use of it.

To set a passphrase, enter it here.

To skip setting a passphrase, hit Return without typing anything.

Whether you set a passphrase or not, you’ll be asked to confirm it.

Enter the passphrase again, or just press Return.

Your keypair has been generated.

Note that the private key is called “id_rsa” and the public key is “id_rsa.pub”, and they’re both in a folder called “.ssh” in your home folder.

The public key (the one ending in .pub) goes on the remote server and you’ll need to put your public key on the server either via cPanel web interface or connecting with a username and password via SSH.

Your public key is a text file with a single long line.

Enter this command to see it:

$ cat ~/.ssh/id_rsa.pub

Open that file in a text editor, and append the entire contents of your public key onto the end of the file.

Once connected, navigate into ~/.ssh/ on the remote server and look for a file called authorized_keys or authorized_keys2.

If you are using the cPanel interface, visit Home >> Security >> SSH Access.

  • Click Manage SSH Keys.
  • Click Import Key.

To use a custom key name, enter the key name in the Choose a name for this key (defaults to id_dsa) text box.

  • Paste the public and private keys into the appropriate text boxes.
  • Click Import.

Make sure that you authorize the key by clicking “Manage“.

A new interface will appear. Click Authorize to authorize the key or Deauthorize to revoke authorization for the key.

Along with your public and private keys, your .ssh folder can contain a file called config containing settings and preferences relating to your keys and servers. There are too many possible options to list here, and not every possibility is supported (or even practical) in every app.

As a basic example, here’s what you’d put in your config so that the key called exampleKey is used when connecting with the username user to the server domain_name.com.

Host domain/name.com
User cPanelusername
IdentityFile "~/.ssh/exampleKey"

This is a great way to tell apps which key file goes with which server, especially if you use non-standard names for your keys, you keep your keys outside of ~/.ssh, or if you use passphrase-encrypted keys, which Transmit cannot validate.

To use Transmit with your cPanel server after the installation:

  • Click to open the Transmit app.
  • Click the “+” sign at the bottom or select “Add New Server” from the “Servers” menu.

You will see all available options.

  • Select SFTP or if you are giving access to your developer using Port 21, select FTP.
  • Type in the name of the server for easy identification.
  • Type in your domain name.
  • Type in your user cPanel username.

If you have followed all the guide above, you can leave the password option blank since your key is already available to use by the app.

  • Either click “Save” or select the paths that you want to access remotely or locally.

This will save the server for you for immediate or future use.

If you simply want to test out things, just use the “Quick Connect” option.

This won’t save the server and you will need to repeat the process when next you access the server.

If you have entered all relevant information correctly, the app will list out all files and directories on your remote cPanel server.

You can either edit, upload or manage all of these right from the user interface.

Do remember though to always backup your files before editing them.

Filezilla:

After your keys have been generated and authorized, you will need to create your SFTP profile in your FileZilla application which requires to steps:

Setting up the SFTP connection profile :

  • Open the FileZilla client.
  • From the top of the home screen, click on Edit and select Settings.
  • On the left side of the menu, expand the Connection section and highlight SFTP.
  • Click on the [Add keyfile…] button and browse your local machine’s directories and select your Private Key file.
  • Using the upper toolbar, click on File and then Site Manager. A popup will appear for you to create a new profile.
  • Click on the New Site.
  • Rename the empty site title, “New Site” to a nickname for your server.

Changing the port to 22 will automatically set the host to https:// making it a secure connection.

The right-hand form will appear brighter, indicating you can now enter data in it.

  • Now, under the General tab, fill in the Host (with either an IP address or FQDN) and Port fields (default is 22).
  • In the Protocol drop-down menu, select SFTP – SSH File Transfer Protocol.

More like this:

HostEnter your domain name here. (ie: domain_name.com)
PortSet this to “22”.
ProtocolSet this to “SFTP – SSH File Transfer Protocol”.
Logon TypeSpecify the location of the private key file (in .ppk or .pem format)

In the Edit – Settings menu of the FileZilla client, you can [Add key file…] under Connection – SFTP, and FileZilla can then use the public key authentication in the site manager with the ‘Interactive’ Logon type it connects.

Note: Importing a site’s public key is not supported.

Using PuTTY Tools (Windows only).

To allow the use of RSA/DSA key files with Filezilla, you’ll need to download two more tools from PuTTY: Pageant and (assuming your key file isn’t already in PPK format) PuTTYgen found here: http://www.chiark.greenend.org.uk/~sgtatham/putty/ .

If your key file is already in PuTTY’s PPK format you can skip the following 4 lines.

If your key is in OpenSSH format, you first need to convert it to PuTTY’s PPK format.

To do this,

  • aunch PuTTYgen and from the “Conversions” menu, select the “Import key” option.
  • Select your key and follow the prompts to enter your passphrase.
  • Save your private key.

Now run Pageant.

In your system tray, you’ll see the Pageant icon appear.

  • Right-click the icon and select “Add Key” and select your private key (PPK) file.
  • Follow the prompt to enter your passphrase and you’re done.

You can now simply launch FileZilla and connect to your server using SFTP with a username and an empty password.

Don’t forget to close pageant when you’re done.

This also works with the portable versions of FileZilla and PuTTY tools.

Alternatively, use WinSCP which has PuTTYgen included by default.

You can download it from here: https://winscp.net/eng/download.php

Filezilla on a Mac:

If for some reason you are not using ssh-agent and on a Mac, don’t worry about ssh key conversion.

Just import your key via Settings and then use Normal mode in your site connection definition. The imported key will get used.

The following instructions assume you have a working SSH configuration which allows you to ssh to the same host without a password.

  • In FileZilla -> Settings … select Connection -> SFTP
  • Press the Add key file… button
  • Press Command-Shift-G to bring up a path selection window and type “~/.ssh”
  • Select the “id_rsa” key file and click Open (this imports the key)
  • Click OK to close the Settings dialog
  • Open File -> Site Manager …
  • Select the site with which you want to use the key
  • Choose Protocol “SFTP” and select Logon Type “Normal”. Don’t worry about a password if you key file doesn’t have a password
  • Click Connect and you’ll see your files.

Again, a little exploration might be in order to get the best of this.

How To Use SCP For cPanel Login & cPanel File Management

SCP (Secure copy protocol) is a means based on the Secure Shell (SSH) protocol that you can use to securely transfer files between a local host and a remote host or between two remote hosts.

Typically, a syntax of scp program is like the syntax of cp (copy):

Copying file to host:

scp sourcefile user@host:directory/targetfile

Copying file from host:


scp user@host:directory/sourcefile targetfile
scp -r user@host:directory/sourcefolder targetfolder

Note that if the remote host uses a port other than the default of 22 (as some of our servers do), it can be specified in the command.

For example, copying a file from host:

scp -P 2222 user@host:directory/sourcefile targetfile

See more examples at:

https://linux.die.net/man/1/scp
http://www.hypexr.org/linux_scp_help.php
https://haydenjames.io/linux-securely-copy-files-using-scp/
https://www.garron.me/en/articles/scp.html
https://kb.iu.edu/d/agye

For more deeper info, use:

$ man scp

or

$ info scp

Published by Trax Armstrong

A figment of someone's imagination that doesn't really exist. He lives inside a sci-fi simulation, reads philosophical and metaphysical books when he is not fighting aliens that want to steal his soul & always quote Star Trek to make his points.

Leave a comment

Leave a Reply

%d bloggers like this: