Giving Root Access to the ftp Server:

• Check whether the root access is assigned or not as follows

[root@sys2 ~]# ftp 192.168.1.5
Connected to 192.168.1.5 (192.168.1.5).
220 (vsFTPd 2.2.2)
Name (192.168.1.5:root): root
530 Permission denied.
Login failed.
ftp>

 

from the above output the root login is disabled by default.

• To allow the root access comment the username root in the files “/etc/vsftpd/ftpusers” and “/etc/vsftpd/user_list” on the server.

[root@sys1 ~]# vim /etc/vsftpd/ftpusers
# Users that are not allowed to login via ftp
#root
bin
daemon
adm
lp
sync

 

[root@sys1 ~]# vim /etc/vsftpd/user_list
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
#root
bin
daemon
adm
lp
sync

 

• Restart the ftp service

[root@sys1 ~]# service vsftpd restart
Shutting down vsftpd:                                       [ OK ]
Starting vsftpd for vsftpd:                                 [ OK ]

 

• Now go to client and try to login as the root.

[root@sys2 ~]# ftp 192.168.1.5
Connected to 192.168.1.5 (192.168.1.5).
220 (vsFTPd 2.2.2)
Name (192.168.1.5:root): root
331 Please specify the password.
Password:
500 OOPS: cannot change directory:/root
Login failed.

 

Now also you are getting the login failed error this is due to selinux.

• Now go to the server and set the Boolean to on.

[root@sys1 ~]# getsebool -a | grep ftp
allow_ftpd_anon_write --> on
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> off

 

• Set the above highlighted Boolean to on.

[root@sys1 ~]# setsebool -P ftp_home_dir on
[root@sys1 ~]# getsebool -a | grep ftp
allow_ftpd_anon_write --> on
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> on

 

• Now go to the client and try to login as root.

[root@sys2 ~]# ftp 192.168.1.5
Connected to 192.168.1.5 (192.168.1.5).
220 (vsFTPd 2.2.2)
Name (192.168.1.5:root): root
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.

 

Yes ! we are successfully logged in as root.

• After logged in as a root the default directory is /root.

ftp> pwd
257 "/root"
ftp> ls
227 Entering Passive Mode (192,168,1,5,64,68).
150 Here comes the directory listing.
drwxr-xr-x   2  0   0   4096   Mar  08  14:35   Desktop
drwxr-xr-x   2  0   0   4096   Jan  21  20:15   Documents
drwxr-xr-x   2  0   0   4096   Jan  21  20:15   Downloads
drwxr-xr-x   2  0   0   4096   Jan  21  20:15   Music
drwxr-xr-x   2  0   0   4096   Mar  08  14:31   Pictures
drwxr-xr-x   2  0   0   4096   Jan  21  20:15   Public
drwxr-xr-x   2  0   0   4096   Jan  21  20:15   Templates
drwxr-xr-x   2  0   0   4096   Jan  21  20:15   Videos
-rw-------   1  0   0   1459   Jan  21  20:10   anaconda-ks.cfg
-rw-r--r--   1  0   0  49733   Jan  21  20:10   install.log
-rw-r--r--   1  0   0  22773   Jan  21  20:10   install.log.syslog
-rw-r--r--   1  0   0     34   Jan  22  07:28   ith1
-rw-r--r--   1  0   0      0   Feb  02  14:35   ithonours1
drwxr-xr-x   2  0   0   4096   Feb  23  11:17   mysql
226 Directory send OK.

 

Topics Covered