Search My Techie Guy

Showing posts with label ftp. Show all posts
Showing posts with label ftp. Show all posts

Tuesday, July 15, 2014

500 OOPS: cannot change directory:/home/user_name - Problem Solved

OS = Red Hat Enterprise Linux 6.2

Problem:

Created a new user and gave him access to ftp but couldn't login with the error below:

# ftp localhost
Trying ::1...
ftp: connect to address ::1Connection refused
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
220 (vsFTPd 2.2.2)
Name (localhost:root): drivetests
331 Please specify the password.
Password:
500 OOPS: cannot change directory:/home/drivetests
Login failed.
ftp> bye
#

check the current status of your selinux policy:

# getenforce
Enforcing
#

Check the selinux ftp policy status:

# getsebool -a | grep ftp
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> off
ftpd_connect_db --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off


switch on this parameter: ftp_home_dir --> on

# setsebool -P ftp_home_dir on


check again to make sure that it has been switched on:

# getsebool -a | grep ftp
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> on
ftpd_connect_db --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off


Restart the FTP server:

# /etc/init.d/vsftpd restart

Test logging in to ftp again:

# ftp localhost
Trying ::1...
ftp: connect to address ::1Connection refused
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
220 (vsFTPd 2.2.2)
Name (localhost:root):
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> 
ftp> bye
221 Goodbye.

Tuesday, July 1, 2014

How to create a linux user and enable ftp

Here, you will create a linux user account on the command line, and grant that user ftp access:
(Am using SUSE Linux, Enterprise).

1. Create the User Account:

# useradd -d /home/peter -m peter
# passwd peter
#
#

2. Test if ftp service is working (connection refused means that ftp is NOT running):

# ftp localhost
Trying 127.0.0.1...
ftp: connect to address 127.0.0.1: Connection refused
Trying ::1...
ftp: connect: Connection refused

3. Start FTP Server:

/etc/init.d/vsftpd start
Starting vsftpd                                                       done


4. Test Again (Now it's connected):

# ftp localhost
Trying 127.0.0.1...
Connected to localhost.
220 (vsFTPd 2.0.4)
Name (localhost:root): 

5. Try to Login with the user we created (fails):

Name (localhost:root): peter
530 This FTP server is anonymous only.
ftp: Login failed.
ftp>

6. This means that local users are NOT allowed to access the ftp service.

7. So we edit the vsftpd.conf file and remove the hash from this line:

# vi /etc/vsftpd.conf

8. Before:

# Local FTP user Settings

# Uncomment this to allow local users to log in.
#
#local_enable=YES

9. After:

# Local FTP user Settings

# Uncomment this to allow local users to log in.
#
local_enable=YES

10. Restart the vsftpd service

# /etc/init.d/vsftpd restart
Shutting down vsftpd                                                  done
Starting vsftpd                                                       done


11. Try to login Again:

# ftp localhost
Trying 127.0.0.1...
Connected to localhost.
220 (vsFTPd 2.0.4)
Name (localhost:root): peter
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> 
ftp> 

12. Problem Solved :-)