Microsoft Azure Top-up Discounts How to Transfer Files to Azure VM Using SFTP
Introduction: SFTP Is the Calm, Responsible Cousin of File Transfer
So you want to transfer files to an Azure VM using SFTP. Great choice. SFTP (Secure File Transfer Protocol) is like regular FTP’s well-behaved older sibling: it encrypts data in transit, uses SSH under the hood, and generally doesn’t leave your passwords wandering around the network like a lost Roomba. With SFTP, you can reliably move files to a Linux or Windows-hosted setup that supports SSH/SFTP, and you can do it from a graphical client or the command line.
In this guide, we’ll go step-by-step from “What is SFTP again?” to “My deployment files landed successfully.” We’ll cover what you need on the Azure side (networking, users, server configuration), what you need on the client side (SFTP client and connection details), and how to verify you actually uploaded what you think you uploaded. We’ll also handle the most common issues: wrong ports, missing SSH, permissions that make no sense, and firewall rules that act like they’re paid per denial.
Let’s get your files to Azure without turning your life into a detective novel.
Before You Start: The Big Picture and What You’ll Need
Before touching configuration, it helps to understand the players in the scene:
- Azure VM: Your target machine. It must have an SSH server configured to accept SFTP connections.
- Network access: Azure networking and any local firewall must allow inbound connections to the SSH/SFTP port.
- SFTP client: Either a GUI tool (like FileZilla) or a CLI tool (like scp/sftp).
- Credentials: A username and either password or SSH key. Keys are generally better if you like your life and security.
We’ll assume your VM is Linux, because that’s the most typical SFTP story. If you’re on Windows, the concept is similar, but the specifics differ. The principles still hold: SFTP is tied to SSH, and SSH must be enabled and reachable.
Step 1: Confirm Your VM OS and Choose the Right Approach
First, confirm what you’re running:
- Linux VM: Usually you’ll have OpenSSH Server installed (or you install it). SFTP is typically included as part of OpenSSH.
- Windows VM: You may need an SSH server feature or an installed SSH subsystem that supports SFTP.
If you’re not sure, check your Azure portal VM details for the OS. If you see Linux, you’re in familiar territory. If you see Windows, you can still follow the overall structure, but you’ll adjust the server setup portion.
Step 2: Make Sure SSH/SFTP Is Running on the Azure VM
On a Linux VM, you’ll typically need:
- An SSH server installed (often
openssh-server) - The SSH daemon running
- SFTP functionality enabled (usually automatic if SSH is configured correctly)
If you connect to the VM using the Azure portal’s “Run command” or via an existing SSH session, you can check:
- Is the SSH service installed?
- Is it running?
- Microsoft Azure Top-up Discounts Is it listening on the expected port?
Typical checks include looking for the SSH service status and confirming it listens on port 22 (the default). If it’s not running, you install and start it.
Now, a quick reality check: sometimes SFTP is “enabled” but not reachable because SSH is running only on localhost or on a different port. The server can be perfectly healthy and still be unreachable—like a restaurant that’s open but only delivers to planets you can’t visit.
Step 3: Open the Network Ports in Azure (Don’t Skip This Part)
Azure has layers of protection that can block inbound traffic. You may be able to do everything right on the VM and still get denied due to firewall rules. The usual villain is the Network Security Group (NSG) associated with your VM’s subnet or network interface.
To allow SFTP/SSH traffic:
- Go to the Azure portal.
- Open your VM’s networking details.
- Find the Network Security Group (NSG) rules.
- Create or update an inbound rule to allow SSH (commonly TCP port 22).
- Set source appropriately (your IP address is best; “Any” works, but it’s like leaving your front door unlocked and inviting trouble to dinner).
If you changed the SSH port in the VM, use that port here too. Consistency is your best friend. Inconsistency is your enemy wearing a trench coat.
Also remember any other firewall inside the VM (like ufw or iptables) might block the traffic. Azure NSG is not the only bouncer at the club.
Step 4: Verify SSH Connectivity Before Fighting SFTP
Before you try to upload files, verify you can connect to the VM using SSH. If SSH doesn’t work, SFTP won’t either.
From your local machine, you can attempt a connection. Use the VM’s public IP or DNS name and your SSH credentials.
If SSH fails, don’t start tweaking SFTP settings randomly. Instead, focus on:
- Microsoft Azure Top-up Discounts Correct hostname/IP
- Microsoft Azure Top-up Discounts Correct username
- Correct port (22 by default)
- NSG rule allowing inbound traffic
- Local firewall allowing inbound SSH
- VM not blocking auth (wrong keys/password, account locked, etc.)
Microsoft Azure Top-up Discounts Once SSH works, then SFTP is just SSH’s file-delivery side hustle.
Step 5: Understand SFTP User Accounts and Permissions
SFTP logins are typically tied to a normal system user account. The permissions on the target directories matter a lot. Many “SFTP isn’t working” stories are actually “SFTP can connect but cannot write to where you’re trying to upload.”
Here’s what to think about:
- Where are you uploading? Common targets are home directories or a dedicated folder like
/var/www/uploads. - Does the user have write permission? You might need to adjust ownership or permissions.
- Are you using a restricted SFTP user? Some setups use chroot or forced command options. That’s fine, but it means your file paths might be restricted.
A good pattern is to create a dedicated user (for example, sftpuser) with a home directory where uploads are allowed. That way, you don’t accidentally grant access to more of the filesystem than you intended. It’s like giving someone a key to your garden gate, not your entire house.
Step 6: Configure the SSH Server for SFTP (Usually It’s Already There)
On many Linux distros, once openssh-server is installed and running, SFTP works automatically. The SSH daemon provides an SFTP subsystem.
However, if your environment is locked down or customized, you may need to check SSH configuration. Common locations include:
/etc/ssh/sshd_config
Look for settings related to:
- Which ports SSH listens on
- Whether SFTP subsystem is configured
- Whether authentication methods are allowed (password vs key)
If you do modify sshd_config, remember to restart or reload SSH. Otherwise, changes won’t take effect, and you’ll wonder why reality still refuses to comply. (Reality is stubborn. But predictable.)
Step 7: Choose Authentication: Password vs SSH Keys
SFTP supports password authentication (if configured) and SSH key authentication (usually recommended). SSH keys reduce the risk of brute force attacks and make automation smoother.
If you’re using a password, make sure:
- The user’s password is set
- SSH allows password auth for that user or globally
- The account isn’t locked
If you’re using an SSH key, make sure:
- Your public key is present in the user’s
~/.ssh/authorized_keys - File permissions are correct (SSH is picky; it’s like a cat demanding the exact chair temperature)
Typical key permission expectations on Linux include that ~/.ssh is not world-writable and that authorized_keys is readable by the user.
Step 8: Collect Connection Details You’ll Need on the Client
To connect from your machine, you’ll need:
- Host: VM public IP address or DNS name
- Port: Typically 22 (or whatever you configured)
- Username: The SFTP/SSH account name on the VM
- Authentication: Password or private key
- Target directory: Where you want files to land
Write these down. Future you will thank you. Or future you will sigh dramatically while searching for them, like they’re hidden behind a couch cushion labeled “IMPORTANT STUFF.”
Microsoft Azure Top-up Discounts Step 9: Transfer Files Using a Graphical Client (FileZilla Example)
If you prefer a visual interface, SFTP clients like FileZilla are popular. The basic steps:
- Open FileZilla.
- Go to the SFTP connection settings.
- Enter the VM host (public IP or hostname).
- Set port (22 default).
- Enter the username.
- Select authentication (password or private key).
- Click Connect.
Once connected:
- Browse your local files on the left.
- Browse the remote directories on the right.
- Upload by dragging files from left to right (or using the upload button).
If it connects but uploading fails, check:
- Remote directory write permissions
- Whether the user is restricted (chroot or forced directory)
- Whether you’re trying to upload to a directory that doesn’t exist
Also, pay attention to the status messages at the bottom. They can be oddly specific. Unfortunately, they speak in “technical truth,” so you’ll need to interpret them like a weather app forecasting disappointment.
Step 10: Transfer Files Using Command Line (sftp Tool)
If you like doing things the “I’m powerful and I don’t need buttons” way, use the command line. Most systems include an sftp client.
A typical interactive session looks like this:
- Run:
sftp -P 22 username@your-vm-ip - When prompted, authenticate via password or key
Once inside the sftp> prompt, you can use commands like:
pwdto check the remote working directorycd /pathto change remote directorylcd /local/pathto change local directoryput filenameto upload a filemput *.zipto upload multiple files
For example, if you want to upload a file to a target folder you might do:
- Change remote directory to the upload destination
- Upload the file
Then verify it landed correctly with ls on the remote side.
Step 11: Automate Transfers (Optional but Delightful)
If you deploy often, you might want automation. You can script sftp batch mode or use alternative tools like scp (which uses SSH encryption too) if SFTP specifically isn’t required.
But if you want SFTP specifically, you can write a small script that:
- Microsoft Azure Top-up Discounts Connect using sftp
- Change to the correct remote directory
- Upload files
- Exit
The advantage is consistency: the same commands run each time, without forgetting one tiny step like switching directories. The biggest enemy of automation is… you, but future-you has fewer reasons to panic.
Step 12: Verify the Upload (Because “It Sent” Isn’t the Same as “It Arrived”)
After uploading, verify:
- File exists on the VM
- File size matches expected value
- Permissions are correct (if your application needs them)
From the VM, you can list the directory contents with ls -l and check timestamps and sizes. Or compare checksums if you’re working with critical artifacts. Many deployments don’t require checksums, but some definitely do—especially if files might be large or moved over flaky networks.
If verification fails, do not immediately assume the file is corrupted. Sometimes the issue is that you uploaded to the wrong directory (yes, it happens), or you’re uploading as a user with a different home directory expectation than you think.
Troubleshooting: Common SFTP Problems and How to Fix Them
Problem: “Connection refused” or “Timed out”
This usually means networking/firewall issues. Check:
- NSG inbound rule allows TCP to the SSH port
- VM is running and reachable
- Correct public IP/hostname
- You used the right port
- No local firewall blocks SSH
If you changed SSH port in sshd_config but forgot to update NSG rules, you’ll get exactly this kind of failure. Your server is basically shouting “I’m here!” and Azure is replying “Not today, Satan.”
Problem: “Authentication failed”
This usually indicates credential problems:
- Wrong username
- Password incorrect
- SSH key not authorized
- Key permissions incorrect
- SSH server disallows the authentication method you used
If using a key, ensure your public key is in the correct user’s ~/.ssh/authorized_keys. Also confirm that you’re connecting to the correct user. It’s easy to accidentally set up a key for one account and then connect as another.
Problem: “SFTP works but uploads fail”
This is permissions. Common causes:
- Target directory is not writable by the SFTP user
- Directory ownership mismatch
- SELinux/AppArmor restrictions (on some systems)
- SFTP chroot/restriction preventing access to the desired path
Microsoft Azure Top-up Discounts Fix by ensuring the user can write to the destination. For example, uploading to a directory inside that user’s home directory often avoids permission drama.
If your directory is something like /var/www, you might need to adjust ownership or use a deployment user with correct access rights.
Problem: “No such file or directory” during upload
This happens when the remote path you selected doesn’t exist or differs from what you expect. Double-check remote directories:
- Use
pwdandlson the remote side - Confirm absolute vs relative paths
- Confirm you didn’t assume a home directory location that’s different for the SSH user
Remember: the remote filesystem is not a mirror of your laptop. It’s more like a parallel universe where everything is similar, except when it isn’t.
Problem: Directory listing shows files, but the app can’t read them
Uploads may be successful, but permissions might be too restrictive. Check:
- File ownership
- File permissions (read/write/execute)
- Correct group ownership if your app runs under a specific user or group
Sometimes you need to set the proper permissions after upload, or ensure your deployment user uploads into a directory configured for the application.
Problem: “Permissions are too open” for SSH keys
SSH clients will refuse keys if local permissions are too broad, or if the remote ~/.ssh and authorized_keys have unsafe permissions. Make sure the remote user’s SSH directory and files meet SSH expectations.
This is one of those issues that feels personal, like SSH is judging you for the state of your folders. But once you fix the permissions, things usually behave normally.
Security Tips (So Your Files Don’t Become a Public Mystery)
Since we’re dealing with file transfer over a network, a few security best practices go a long way:
- Prefer SSH keys over passwords
- Restrict inbound SSH access to your IP or a trusted range
- Use a dedicated SFTP user for uploads
- Restrict upload directories (optionally using chroot or forced commands)
- Use strong authentication and disable insecure options if possible
If you do only one security improvement, make it this: don’t expose SSH/SFTP to the entire internet if you can avoid it. You don’t want to be the welcome mat for automated login attempts.
A Practical Example Workflow (End-to-End, No Hand-Waving)
Let’s stitch everything together with a realistic flow:
- Create an Azure VM (Linux) and ensure it has a public IP or DNS name you can reach.
- Install and start OpenSSH server on the VM.
- Ensure SSH is configured to allow SFTP (usually the default behavior).
- Create an NSG inbound rule allowing TCP port 22 from your IP.
- Verify you can connect using SSH.
- Create or use an SFTP user and choose an upload directory (for example,
/home/sftpuser/uploads). - Set ownership/permissions so that the user can write to that directory.
- From your SFTP client, connect to
host:portwith the username and credentials. - Upload files to the target directory.
- Verify from the VM with
ls -land confirm file sizes and timestamps.
If anything fails, refer to the troubleshooting section. Nine times out of ten, it’s a network rule, a permission issue, or a wrong directory. The remaining one time is… you found a corner case. Congratulations. Those are rarer and more educational.
Microsoft Azure Top-up Discounts Frequently Asked Questions (Quick Answers, Reduced Stress)
Do I need FTP installed?
Nope. SFTP is separate and secure. You typically just need SSH/SFTP capabilities on the VM.
What port does SFTP use?
Typically SFTP uses TCP port 22, because it’s implemented through SSH. If you changed SSH configuration to listen on a different port, use that port consistently on both client and NSG.
Is SFTP available on all Azure VM images?
It depends on the image and how it’s configured. Most Linux images support OpenSSH, but you may need to install or configure it. Always check the VM’s actual state.
Can I upload folders, not just files?
Yes. Many clients support uploading directories. With command line, you can use wildcard patterns or recursive upload depending on your client capabilities.
Can I use SFTP for automated deployments?
Absolutely. You can script it or call it from CI/CD. SSH keys and predictable directory permissions make automation much smoother.
Conclusion: You’ve Got This (Your Files Are Not Afraid)
Transferring files to an Azure VM using SFTP is a solid, secure approach, and once you set up SSH access, the actual upload steps are straightforward. The key is getting the fundamentals right: SSH/SFTP must be running, Azure networking must allow inbound connections, and the user must have permissions to write to the destination directory.
If you run into issues, don’t panic and don’t blame SFTP first. Check the connection path, confirm ports and NSG rules, verify authentication, and inspect permissions. Most failures are boring (in a good way): wrong port, blocked firewall, missing key, or incorrect folder permissions.
Now go forth and transfer. Your Azure VM is waiting, holding a tiny digital tray like “Please deliver the artifact.” And this time, you will.

