Uploading Files with SFTP
Connect to your server securely with a free SFTP app, upload and download files, and avoid the mistakes that break sites.
// SFTP connection host: yourdomain.com port: 22 protocol: SFTP (secure) user: your-username folder: public_html/
🧰 What you need first
- Your hosting account
- SFTP or SSH login details from your host
🎯 What you'll learn
- Choose SFTP over plain FTP
- Connect with a free app
- Upload, download and replace files safely
🛠 Tools needed
- An SFTP app
- Your hosting account
SFTP vs FTP
FTP moves files between your computer and your server, but it sends your password and files unencrypted. SFTP does the same job over an encrypted connection.
SFTP
Secure File Transfer Protocol. It runs over SSH, usually on port 22.
Warning: Avoid plain FTP on public Wi-Fi. Anyone on the network could read your password.
Get an SFTP app
Several free, well-rated apps work well. In alphabetical order:
- Cyberduck (Mac and Windows)
- FileZilla (Mac, Windows, Linux)
- WinSCP (Windows)
mC0de isn't paid by any of them. Download from the official website only.
Find your login details
- In cPanel, look for SSH Access or FTP Accounts.
- Note the host (often your domain or server name), port, username and password.
- Some hosts require SSH to be turned on first, or use an SSH key instead of a password.
Connect
- Open your app and create a new connection or site.
- Choose SFTP as the protocol.
- Enter the host, port
22, username and password. - Connect. Your computer shows on one side, your server on the other.
Note: The first time, the app asks you to trust the server's key. That's normal. Accept it.
Move files safely
- Your main site lives in public_html. Extra domains usually have their own folders.
- Drag files from your computer to the server to upload them, or the other way to download.
- Before replacing a file, download the old one so you can put it back.
Permissions
files: 644 (owner can edit, everyone can read)
folders: 755 (owner can edit, everyone can open)
never: 777 (anyone can change it)
Common problems
Connection refused or timed out
Why: Wrong port or protocol, or SSH isn't turned on.
Fix: Check you chose SFTP on port 22 (some hosts use another port). Turn on SSH access in cPanel, or ask support.
My changes don't show up
Why: You uploaded to the wrong folder, or a cache is showing the old version.
Fix: Check you're inside public_html, then clear your site's cache and your browser cache.
Permission denied
Why: The file belongs to another user, or its permissions are too strict.
Fix: Use the File Manager or ask your host to fix the owner.
Key takeaways
Keep going
- Edit files without an app: Your Host's File Manager
- Make sure you can always undo: Setting Up Automatic Backups
Enjoyed this guide?
Support free learning at mC0de.
