Need help?

Our experts have had an average response time of 13.14 minutes in February 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Rsync Permission denied (publickey) error – How we sort it out?

by | Oct 3, 2019

Rsync is a real boon for local and remote file transfers.

But rsync operation often ends up in the “Permission denied (publickey)” error.

Usually, this error shows up when there are problems with rsync permissions.

At Bobcares, we often get requests to fix rsync errors, as a part of our Server Management Services.

Today, let’s discuss various reasons for Rsync permission denied error and see how our Support Engineers fix them.

 

What is Rsync error: permission denied (publickey)?

Rsync stands for remote sync. This a local and remote file synchronization tool.

For instance, rsync minimizes the amount of data transfer by copying portions of a file that have changed.

But in many situations, improper usage can show up errors. A typical rsync error message due to improper user query is as:

Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]

The error code indicates that rsync cannot operate over an ssh connection due to a lack of permission.

Our customers often approach us with such error messages. In such situations, our Support Engineers check the customer query and fix the error.

 

How we fix the Rsync error?

The rsync error we discuss here is mostly a sender-side error.

Usually, this happens when the customer’s query contains improper rsync option or has syntax errors.

Our Dedicated Engineers with expertise over a decade checks the customer query and fixes the error. Today, let’s see a few such cases in detail.

 

1. Improper usage of rsync switch

Recently, one of our customers approached us with an rsync problem. He was using the rsync command as:

rsync -i "XXX.pem" -anv webapps ubuntu@xx.xx.xxx.xx:/home/ubuntu/

Unfortunately, it ended up in the Permission denied (publickey) error.

Our Support Engineers checked the query and we noticed an improper usage of -i in the query.

We checked if the user can ssh into the specified server. We also verified the permissions of the XXX.pem file. Finally, we corrected the query to,

rsync -e "ssh -i XXX.pem" -anv webapps ubuntu@xx.xx.xxx.xx:/home/ubuntu/

This fixed the error and the rsync operation was successful.

 

2. Wrong user privileges

Similarly, Rsync errors can also occur due to insufficient user privileges too. The customer was executing the following query.

sudo rsync -avz -e "ssh -p "

This ended up in the rsync permission denied error. Our Dedicated Engineers started debugging the reason for the error.

Finally, we found that the user that was running rsync did not have sudo privileges. But he executed the query as sudo. Thus the query ended up in the error. So, we changed the query to

rsync -avz -e "ssh -p "

This query could successfully run the operation. And this fixed the error.

 

3. Overwriting SSH files

In some situations, the rsync operations overwrite the existing SSH file in the destination server. When a user tries to ssh into this server or tries to rsync using ssh it ends up in error.

When our customers approach us with such an error, we check the SSH settings in the server. Our Dedicated Engineers reset back the ssh configuration to fix the error. We make sure to configure the sshd_config file properly. Additionally, we set PermitRootLogin to yes and PubkeyAuthentication to yes for easy remote file exchange.

 

[Need help in fixing Rsync permission denied error? – We will fix it for you.]

 

Conclusion

In short, the rsync query ends up in Permission denied publickey error due to improper usage of rsync options, wrong user privileges, overwriting of ssh files, and so on. Today, we saw how our Support Engineers fix these errors for our customers.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

1 Comment

  1. Daren Lee

    A common reason for this error is when public keys are used but then “sudo” is put before the rsync command. When you do that, the /root/.ssh keys are used and may be different from your user’s account keys (/home/username/.ssh) . Make sure the /root/.ssh folder has valid keys for the destination address if you use “sudo rsync user@xxx.xxx.xxx.xxx:/path”

    Reply

Submit a Comment

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

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF