×


curl 9 Server denied you to change to the given directory

curl is a widely used because of its ability to be flexible and complete complex tasks. For example, you can use curl for things like user authentication, HTTP post, SSL connections, proxy support, FTP uploads, and more! You can also do simple things with curl, such as download web pages and web images.

curl 9 Server denied you to change to the given directory occurs when we are denied access to the resource given in the URL.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to fix curl related errors.

In this context, we shall look into how to resolve this curl error.


Nature and fixes for 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:blahroot@192.168.8.172/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:

curl “ftp://root:blahroot@192.168.8.192//var/tmp/x.html”

We can also try fiddling with curl’s option –ftp-method


–ftp-method [method]

The method argument should be one of the following alternatives:


multicwd

A default but slowest behavior, multicwd curl does a single CWD operation for each path part in the given URL.


nocwd

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

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’.


Solution to this curl error

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 curl error? We'd be happy to assist you. ]


Conclusion

This article will guide you on steps to fix curl 9 Server denied you to change to the given directory. This #curl #error occurs when we are denied access to the resource given in the URL.

Curl is a #command line tool and library which implements protocols like #HTTP, #HTTPS, FTP and so on. Curl also supports HTTPS protocol which is secure version of the HTTP.

curl is a widely used because of its ability to be flexible and complete complex tasks. For example, you can use curl for things like user authentication, HTTP post, #SSL connections, proxy support, FTP uploads, and more! You can also do simple things with curl, such as #download web pages and web images.