curl 9 Server denied you to change to the given directory occurs when we are denied access to the resource given in the URL.
As part of our Server Management Services, we assist our customers with several such errors.
Today, let us see an effective solution in order to fix this error.
curl 9 Server denied you to change to the given directory
One of our customers came across this error while trying to import some VMs into OVM. On checking the issue we found that this error occurs when we are denied access to the resource given in the URL.
Similarly, if we try to FTP to one of the servers and change the remote directory it could lead us to this error.
Since the error was very explicit ‘Server denied you to change to the given directory,’ it has nothing to do with CURL. It is simply an access issue. Adding a username and password can resolve the issue.
It does not work with curl, as curl uses a standard FTP process, which requires a login before changing the relevant directory. However, since there is no automatic directory redirection it works fine on the browser.
The following is the command we use:
curl -v “ftp://root:email@example.com/var/tmp/x.html”
Since the pathname is relative, rather than absolute the directory misunderstands as /root/var/tmp which does not exist.
To give an absolute pathname, we need to provide an extra slash as given below:
We can also try fiddling with curl’s option –ftp-method
The method argument should be one of the following alternatives:
A default but slowest behavior, multicwd curl does a single CWD operation for each path part in the given URL.
The fastest behavior, nocwd curl does no CWD at all. CURL will do SIZE, RETR, STOR, etc, and give a full path to the server for all these commands.
singlecwd curl does one CWD with the full target directory and then operates on the file “normally”. It is somewhat more preferable than ‘nocwd’ but without the full penalty of ‘multicwd’.
In order to solve the error, we need to check the default landing directory in the vsftpd.conf file and mention the repo path in the /etc/yum.repos.d/<repo File Name> minus the landing directory.
vsftp default directory is /var/ftp and repos directory is /var/ftp/pub/yum/rhel6 [root@test ~]# cat /etc/yum.repos.d/local.repo [rhel6] name=rhel6 baseurl=ftp://ip of the server/pub/yum/rhel6 gpgcheck=0 enabled=1 [root@test ~]# [root@test ~]# yum repolist Loaded plugins: product-id, security, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. rhel6 | 3.6 kB 00:00 repo id repo name status rhel6 rhel6 3,785 repolist: 3,785
[Stuck with the error? We’d be happy to assist you]
To conclude, this error occurs when we are denied access to the resource given in the URL. today, we saw an effective way our Support Engineers employ in order to fix it.