VOOZH about

URL: https://www.digitalocean.com/community/tutorials/how-to-use-sftp-to-securely-transfer-files-with-a-remote-server?comment=12964

โ‡ฑ How To Use SFTP to Securely Transfer Files with a Remote Server | DigitalOcean


How To Use SFTP to Securely Transfer Files with a Remote Server

Updated on January 30, 2026
๐Ÿ‘ How To Use SFTP to Securely Transfer Files with a Remote Server

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

Former Senior Technical Writer at DigitalOcean, specializing in DevOps topics across multiple Linux distributions, including Ubuntu 18.04, 20.04, 22.04, as well as Debian 10 and 11.

๐Ÿ‘ Anish Singh Walia
Anish Singh Walia
Editor
Sr Technical Content Strategist and Team Lead
See author profile

I help Businesses scale with AI x SEO x (authentic) Content that revives traffic and keeps leads flowing | 3,000,000+ Average monthly readers on Medium | Sr Technical Writer(Team Lead) @ DigitalOcean | Ex-Cloud Consultant @ AMEX | Ex-Site Reliability Engineer(DevOps)@Nutanix

๐Ÿ‘ Manikandan Kurup
Manikandan Kurup
Editor
Senior Technical Content Engineer I
See author profile

With over 6 years of experience in tech publishing, Mani has edited and published more than 75 books covering a wide range of data science topics. Known for his strong attention to detail and technical knowledge, Mani specializes in creating clear, concise, and easy-to-understand content tailored for developers.

Category:

Still looking for an answer?

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Easier to use FilaZilla - hopefully my tutorial will be here soon.

@Samuel,

Sorry to steal your thunder: <a href=โ€œhttps://www.digitalocean.com/community/articles/how-to-use-filezilla-to-transfer-and-manage-files-securely-on-your-vpsโ€>How To Use Filezilla to Transfer and Manage Files Securely on your VPS</a>.

-r works with put ?? i am trying , put -r localfile , and it is saying , invalid flag -r

Please help. Using โ€œput -r localDirectoryโ€ as a template (I want to upload all the files and folders from a folder on my local machine) I ran: sftp> lpwd Local working directory: /Users/Larry/Documents/Website sftp> put -r .

But the results had errors: Uploading ./ to /var/www/html/. remote open(โ€œ/var/www/html/.DS_Storeโ€): Permission denied Uploading of file ./.DS_Store to /var/www/html/.DS_Store failed! remote open(โ€œ/var/www/html/.htaccessโ€): Permission denied Uploading of file ./.htaccess to /var/www/html/.htaccess failed! remote open(โ€œ/var/www/html/index.phpโ€): Permission denied Uploading of file ./index.php to /var/www/html/index.php failed!

Not sure what is wrong, or how to fix it. Perhaps locally I have to be one directory above the desired folder to copy?

sftp> lcd โ€ฆ sftp> lpwd Local working directory: /Users/Larry/Documents sftp> put -r Website Uploading Website/ to /var/www/html/Website Couldnโ€™t canonicalise: No such file or directory Unable to canonicalise path โ€œ/var/www/html/Websiteโ€ sftp>

Larry: It looks like youโ€™re trying to upload files into a directory on the remote server that you do not have permission to write to.

There are a few ways around this. You could upload them to a directory on the remote server that you do have access to, like your home directory, and then sign in through SSH and move the files over to the correct location (using sudo or by signing in with root).

Another alternative is to log in as the root user when connecting through SFTP by giving a command like sftp root@your_server_ip. You would then have adequate permissions to transfer the files to the web root as you are attempting to do.

Please write back if you have more questions.

I had changed my ssh port when i configured my server so i use for example ssh -p 4444 username@server_ip_addr

but how can i do the same for sftp i tried sftp -p 4444 username@server_ip_addr but i did not work connection closing

You need to give the argument -oPort

sftp -oPort 4444 username@server_ip_addr

Hey, I can ssh onto my droplet, but if I type โ€œputโ€, it says โ€œNo command โ€˜putโ€™ foundโ€. It does the same for commands like โ€œlpwdโ€ and โ€œlcdโ€. Any idea about whatโ€™s happening?

alishaaukani+digoc:

You need to use the <code>sftp</code> command instead of <code>ssh</code> when you wish to use the SFTP functionality. This will take you into an SFTP session instead of a normal SSH session, and allow you to use the commands you mention and transfer files.

Let me know if you have any additional questions.

๐Ÿ‘ Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and AI-native businesses

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOceanโ€™s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow โ€” whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

ยฉ 2026 DigitalOcean, LLC.Sitemap.
Dark mode is coming soon.