Hosting & Deployment

How to Upload a Website With SFTP: 7 Proven Easy Steps

0

How to Upload a Website With SFTP is an important skill for beginners, web developers, freelancers, and website administrators who need to transfer website files securely to a web server. SFTP allows you to upload, download, rename, delete, and manage files on a remote server through an encrypted connection.

Unlike traditional FTP, SFTP works through the SSH protocol and encrypts the connection between your computer and the server. This makes it a safer option for transferring website files, especially when you are working with sensitive server information.

In this beginner-friendly guide, you will learn How to Upload a Website With SFTP from start to finish. We will cover SFTP requirements, choosing an SFTP client, connecting to your server, uploading files, setting permissions, configuring the document root, testing your website, troubleshooting common errors, and following security best practices.

How to Upload a Website With SFTP

What Is SFTP?

Before learning How to Upload a Website With SFTP, it is important to understand what SFTP means.

SFTP stands for SSH File Transfer Protocol. It is a secure method for transferring and managing files between your local computer and a remote server.

An SFTP connection normally uses SSH authentication and encryption. This means your login credentials and transferred files are protected while traveling between your computer and the server.

SFTP can be used to:

  • Upload website files
  • Download files from a server
  • Create directories
  • Rename files
  • Delete files
  • Change file permissions
  • Backup website files
  • Move website assets
  • Manage application files

The OpenSSH documentation provides official information about SSH and related tools used for secure server access.

Understanding SFTP is the foundation of How to Upload a Website With SFTP.

SFTP vs FTP: What Is the Difference?

Beginners often confuse SFTP with FTP.

Although both can transfer files, they use different protocols.

FTP

FTP stands for File Transfer Protocol. Traditional FTP does not provide the same level of encryption by default, so credentials and data may be exposed depending on the connection configuration.

SFTP

SFTP stands for SSH File Transfer Protocol. It operates through SSH and provides an encrypted connection.

For website administration, SFTP is generally preferable when your hosting provider supports it.

Here is a simple comparison:

FeatureFTPSFTP
EncryptionNot by defaultYes
Uses SSHNoYes
Secure credential transferDepends on configurationYes
Common port2122
File managementYesYes

Knowing the difference between FTP and SFTP helps you understand How to Upload a Website With SFTP and why SFTP is commonly recommended for secure file transfers.

What Do You Need Before Uploading a Website With SFTP?

Before starting How to Upload a Website With SFTP, collect the connection information from your hosting provider or server administrator.

You normally need:

  • SFTP hostname
  • SFTP username
  • SFTP password or SSH private key
  • SFTP port
  • Website document root
  • Your website files

A typical SFTP configuration might look like:

Host: example.com
Username: website_user
Password: ********
Port: 22
Protocol: SFTP

Your hosting provider may use the server’s IP address instead of a domain name.

For example:

Host: 203.0.113.10
Port: 22

Do not guess the SFTP credentials. Use the information provided by your hosting provider or server administrator.

Step 1: Prepare Your Website Files

The first practical step in How to Upload a Website With SFTP is preparing the files on your computer.

For example, a basic PHP website might contain:

my-website/
├── index.php
├── about.php
├── contact.php
├── css/
│   └── style.css
├── js/
│   └── script.js
├── images/
│   └── logo.png
└── includes/
    └── config.php

Before uploading the website, check that all required files are present.

If you are uploading a PHP application, make sure configuration files, assets, and required directories are included.

For a static HTML website, your structure may look like:

website/
├── index.html
├── about.html
├── contact.html
├── css/
├── js/
└── images/

The exact structure depends on your project.

Preparing your files correctly is an important part of How to Upload a Website With SFTP.

Step 2: Install an SFTP Client

To learn How to Upload a Website With SFTP, you need an SFTP client.

Popular options include:

  • FileZilla
  • WinSCP
  • Cyberduck
  • Command-line SFTP

For beginners using Windows, graphical SFTP applications can make file transfers easier.

FileZilla

FileZilla is a popular cross-platform file transfer application that supports SFTP.

Download it from the official website and install it on your computer.

When downloading any server-management software, use the official website rather than an unknown third-party download site.

WinSCP

WinSCP is another popular Windows application that supports SFTP and SSH-based file management.

Both graphical applications provide a local file panel and a remote server panel, making How to Upload a Website With SFTP easier to understand.

Step 3: Connect to Your Server Using SFTP

After installing an SFTP client, create a new connection.

Enter the server details provided by your hosting provider.

For example:

File protocol: SFTP
Host name: example.com
Port number: 22
User name: website_user
Password: your_password

If your server uses SSH keys, select the appropriate private key instead of entering a password.

Then click Connect.

The first time you connect to a new server, your SFTP client may display a server host-key or fingerprint warning.

Verify the fingerprint with your hosting provider or server administrator when possible before accepting it.

This verification helps protect against connecting to an unexpected server.

Step 4: Find the Website Document Root

Once connected, the SFTP client normally displays two areas:

LOCAL COMPUTER              REMOTE SERVER

Your website files          Server directories

The left side represents your computer.

The right side represents the server.

Your website needs to be uploaded to the correct document root.

Depending on the hosting environment, it could be:

public_html/

or:

/var/www/html/

or another directory configured by the server administrator.

Some hosting providers use directories such as:

www/
htdocs/
httpdocs/

Do not assume that public_html is always correct.

If you are unsure, check your hosting provider’s documentation or ask the server administrator.

Finding the correct document root is one of the most important parts of How to Upload a Website With SFTP.

Step 5: Upload Your Website Files

Now you can upload the website.

Open your local website directory on the left side of your SFTP client.

Open the correct document root on the remote server.

Then select your website files and upload them.

For example:

Local:
my-website/
    index.php
    css/
    images/
    js/

Remote:
public_html/
    index.php
    css/
    images/
    js/

Make sure index.php or index.html is located in the correct document root if it is the main entry point of your website.

Depending on the number and size of your files, the upload may take several minutes.

Do not close the SFTP client while the transfer is still running.

Step 6: Verify the Uploaded Files

After completing the upload, verify that the files actually reached the server.

Check:

  • index.php or index.html
  • CSS files
  • JavaScript files
  • Images
  • Fonts
  • Configuration files
  • Application directories

Compare the local and remote directory structures.

For example:

Local Website
├── index.php
├── css/
├── js/
└── images/

Remote Website
├── index.php
├── css/
├── js/
└── images/

If a large number of files failed to upload, review the SFTP client’s transfer log.

Verifying the transfer is an important part of How to Upload a Website With SFTP because an incomplete upload can cause broken pages and missing resources.

Step 7: Set Correct File Permissions

File permissions determine who can read, write, or execute files on a Linux server.

Incorrect permissions can cause website errors.

For many Linux-hosted websites, common starting points are:

Files: 644
Directories: 755

However, these are not universal rules.

Your hosting environment and application may require different permissions.

Avoid setting everything to:

777

unless you have a specific, well-understood reason.

Giving excessive permissions can create security risks.

For PHP applications, writable directories may need special permissions depending on how the application handles uploads, cache files, logs, or generated content.

This is another important consideration when learning How to Upload a Website With SFTP.

How to Change File Permissions With SFTP

Most graphical SFTP applications allow you to right-click a file or directory and choose a permissions option.

You may see values such as:

Owner: Read Write
Group: Read
Public: Read

This corresponds to:

644

For directories, you may use:

755

Again, use the permissions required by your specific hosting environment rather than blindly applying a single permission value everywhere.

How to Upload a PHP Website With SFTP

If you are uploading a PHP website, uploading the files is only one part of the process.

The server must also support PHP.

For example, if your website requires PHP 8.3, the server should have a compatible PHP environment.

You should also verify required PHP extensions.

A PHP website may depend on extensions such as:

mysqli
pdo_mysql
curl
mbstring
gd
zip
openssl

The exact extensions depend on your application.

For PHP configuration information, refer to the official PHP documentation.

After uploading the PHP files, open your website in a browser:

https://example.com

If the PHP application displays an error, check the PHP and web server logs.

How to Upload a Static Website With SFTP

Uploading a static HTML website is usually simpler.

You may only need:

index.html
style.css
script.js
images/

Upload these files to the website’s document root.

For example:

public_html/
├── index.html
├── style.css
├── script.js
└── images/

Then visit your domain.

If the homepage loads correctly, check the other pages and assets.

[Internal link: How to Host an HTML Website on cPanel]

How to Upload a Website With SFTP Using the Command Line

If you are comfortable with the terminal, you can use the built-in sftp command.

A typical connection looks like:

sftp username@example.com

If the server uses a different port:

sftp -P 2222 username@example.com

After connecting, you can use commands such as:

ls
cd public_html
put index.html

To upload an entire directory recursively, you can use:

put -r website/

To download files:

get index.html

To download a directory:

get -r images/

Command-line SFTP is useful when working with Linux servers or automating deployments.

For more information, see the OpenBSD SFTP manual.

How to Upload a Website With SFTP Using an SSH Key

SSH keys are often preferred for server administration because they can provide strong authentication without requiring you to enter a password for every connection.

The basic setup involves:

Your Computer
     ↓
Private Key
     ↓
SSH/SFTP Server
     ↑
Public Key

The private key should remain securely stored on your computer.

Never upload or share your private SSH key with other people.

If your hosting provider supports SSH key authentication, follow its instructions for generating and registering a key.

Once configured, your SFTP client can use the private key when connecting.

Common SFTP Errors and How to Fix Them

When learning How to Upload a Website With SFTP, you may encounter connection or transfer errors.

Connection Refused

A connection-refused error can occur when:

  • SSH/SFTP is disabled
  • The port is incorrect
  • A firewall is blocking the connection
  • The server is unavailable

Verify the SFTP host and port with your hosting provider.

Authentication Failed

This usually indicates an incorrect username, password, or SSH key.

Check your credentials carefully.

If using an SSH key, verify that the correct private key is selected.

Permission Denied

A permission error can occur when your SFTP account does not have access to the destination directory.

You may need to upload to a different directory or ask the server administrator to change the account’s permissions.

File Not Found

If your website loads but images or CSS files are missing, check the file paths.

For example:

<img src="images/logo.png" alt="Website Logo">

Make sure:

images/logo.png

actually exists on the server.

Website Shows a 403 Error

A 403 Forbidden error can be caused by incorrect permissions, server configuration, directory restrictions, or missing index files.

Check the web server configuration and file permissions.

Website Shows a 500 Error

A 500 Internal Server Error can be caused by:

  • PHP errors
  • Incorrect .htaccess
  • Incompatible PHP version
  • Incorrect permissions
  • Server configuration problems

Check the server error logs for the exact cause.

SFTP Security Best Practices

Security is an important part of How to Upload a Website With SFTP.

Follow these practices:

Use SFTP Instead of Unencrypted FTP

When available, prefer SFTP for secure file transfers.

Protect Your Password

Do not share your SFTP password through public messages or unsecured documents.

Use SSH Keys Where Appropriate

SSH keys can provide strong authentication and are useful for server administration.

Verify Server Fingerprints

When connecting to a server for the first time, verify its host key or fingerprint when possible.

Use the Correct Permissions

Avoid unnecessarily broad permissions such as 777.

Keep Your SFTP Client Updated

Use a current version of your SFTP software to benefit from security and bug fixes.

Remove Unnecessary Files

After uploading your website, remove temporary archives, database dumps, installation files, and other sensitive files that are not required.

For example, do not leave:

database.sql
backup.zip
website-old.zip
test.php

inside a publicly accessible directory.

SFTP Website Upload vs cPanel File Manager

Beginners may wonder whether they should use SFTP or cPanel’s File Manager.

Both methods can work, but they are useful in different situations.

FeatureSFTPcPanel File Manager
Large file transfersGoodDepends on hosting
Secure connectionYesHTTPS-based interface
Bulk file managementExcellentGood
Desktop workflowExcellentNo installation
SSH-based accessYesNo
Remote server managementExcellentLimited

SFTP is especially useful when you regularly upload and manage many website files.

[Internal link: How to Upload a Website in cPanel]

How to Upload a Website With SFTP After a Server Migration

SFTP is also useful when moving a website between servers.

A typical migration process is:

Old Server
    ↓
Download Website Files
    ↓
Local Computer
    ↓
Connect to New Server
    ↓
Upload Website Files
    ↓
Configure Database
    ↓
Update DNS
    ↓
Test Website

If your PHP website uses a database, remember that SFTP only transfers files. You must separately migrate the MySQL or MariaDB database.

[Internal link: How to Migrate a PHP Website to a New Server]

How to Check Your Website After Uploading

After completing How to Upload a Website With SFTP, test your website carefully.

Open the homepage and check:

  • Page loading
  • Navigation
  • Images
  • CSS
  • JavaScript
  • Forms
  • Login
  • Search
  • Database functionality
  • File uploads
  • HTTPS

You can also open your browser’s developer tools and check for:

404 errors
500 errors
Mixed-content warnings
JavaScript errors

If everything works correctly, the upload was successful.

Website Upload Checklist

Use this checklist when following How to Upload a Website With SFTP:

  • Prepare website files
  • Obtain SFTP credentials
  • Confirm SFTP hostname
  • Confirm SFTP port
  • Install an SFTP client
  • Select SFTP as the protocol
  • Connect to the server
  • Verify the server fingerprint
  • Find the document root
  • Upload website files
  • Verify transferred files
  • Check file permissions
  • Configure PHP if required
  • Test the homepage
  • Test images and CSS
  • Test forms and applications
  • Check server error logs
  • Remove temporary files
  • Confirm HTTPS works

Frequently Asked Questions

Is SFTP better than FTP for uploading a website?

SFTP provides an encrypted SSH-based connection and is generally preferred when secure file transfer is available. FTP and SFTP are different protocols, even though both can transfer files.

What port does SFTP use?

SFTP commonly uses port 22, which is the standard SSH port. However, a server administrator may configure SSH/SFTP to use a different port.

Can I upload a PHP website using SFTP?

Yes. SFTP can transfer PHP files and other website assets. However, the server must also have a compatible PHP environment configured to execute the PHP application.

Where should I upload my website files?

Upload them to the document root configured for your domain. Common directories include public_html, www, htdocs, or /var/www/html, depending on the hosting environment.

Do I need SFTP to host a website?

No. SFTP is a method for securely transferring files to a server. Your hosting provider may also offer Git deployment, a control panel, CI/CD deployment, or other methods.

Why is my uploaded website showing a 403 error?

A 403 error can be related to permissions, server configuration, directory restrictions, or missing index files. Check the document root and server logs.

Why is my PHP website showing a 500 error after uploading?

Check the PHP version, required extensions, file permissions, .htaccess configuration, and server error logs. A PHP syntax or compatibility error can also cause a 500 response.

Useful External Resources

For SFTP and SSH information, the OpenSSH official website provides authoritative documentation.

For PHP configuration and server requirements, visit the official PHP documentation.

If you use FileZilla, refer to the official FileZilla website for the latest SFTP client information.

These resources can help you understand How to Upload a Website With SFTP and troubleshoot connection or file-transfer problems.

Conclusion

Learning How to Upload a Website With SFTP is an essential skill for anyone managing websites or web servers. SFTP provides a secure way to transfer website files between your computer and a remote server.

The basic process is simple: prepare your website files, obtain your SFTP credentials, install an SFTP client, connect to the server, locate the correct document root, upload your files, verify permissions, and test the website.

If you are uploading a PHP website, remember that transferring the files is only one part of the process. You also need a compatible PHP version, required extensions, database configuration, and correct server settings.

Always protect your SFTP credentials, use strong authentication, avoid unnecessary file permissions, and remove temporary or sensitive files from publicly accessible directories.

Once you understand How to Upload a Website With SFTP, you can confidently upload new websites, update existing projects, transfer website files during migrations, and manage files on remote servers securely.

How to Create a MySQL Database in cPanel: 7 Proven Easy Steps

Previous article

How to Upload a Website With FTP: 7 Proven Easy Steps

Next article

Comments

Leave a reply

Your email address will not be published. Required fields are marked *