CentOS 6 : Problem with FTP login - 500 OOPS cannot change directory
The problem described as below (the IP address below is only an example, for security reasons):
1
2
3
4
5
6
7
8
9
10
11
| [root@optiflex ~]# ftp 10.10.10.10Connected to 10.10.10.10.220 (vsFTPd 2.2.2)530 Please login with USER and PASS.530 Please login with USER and PASS.KERBEROS_V4 rejected as an authentication typeName (10.10.10.10:root): golduser331 Please specify the password.Password:500 OOPS: cannot change directory:/home/golduserLogin failed. |
As we can see above, the FTP login failures occur because FTP can not change directory to the user's home directory (in this case it is /home/golduser).
To fix this problem, then here's how i done it. First, I do log on to the web server through an SSH connection with user 'root'.
Once the login is successful, then I need to see the booleans value of SELinux policy, filtering on whom containing the word 'ftp':
1
2
3
4
5
6
7
8
9
10
11
12
13
| [root@goldsrv ~]# getsebool -a | grep ftpallow_ftpd_anon_write --> offallow_ftpd_full_access --> offallow_ftpd_use_cifs --> offallow_ftpd_use_nfs --> offftp_home_dir --> offftpd_connect_db --> offhttpd_enable_ftp_server --> offsftpd_anon_write --> offsftpd_enable_homedirs --> offsftpd_full_access --> offsftpd_write_ssh_home --> offtftp_anon_write --> off |
As we can see above, the ftp_home_dir boolean is set to off, that's preventing the FTP daemon (vsftpd) from reading and writing to files in user home directories.
To change the boolean value to on, perform the following steps (the '-P' parameter means permanent):
1
| [root@goldsrv ~]# setsebool -P ftp_home_dir on |
Please check back if ftp_home_dir values have changed:
1
2
3
4
5
6
7
8
9
10
11
12
13
| [root@goldsrv ~]# getsebool -a | grep ftpallow_ftpd_anon_write --> offallow_ftpd_full_access --> offallow_ftpd_use_cifs --> offallow_ftpd_use_nfs --> offftp_home_dir --> onftpd_connect_db --> offhttpd_enable_ftp_server --> offsftpd_anon_write --> offsftpd_enable_homedirs --> offsftpd_full_access --> offsftpd_write_ssh_home --> offtftp_anon_write --> off |
Aaah, the ftp_home_dir already set to on :-) After doing the steps above, I can log into my web server with FTP connection without any problems. Hope this article helps those of you who encountered similar problems.
Comments