Friday, June 26, 2015

Setup FTP server on CentOS 7


root@nirav:~# yum install vsftpd
 

root@nirav:~# cp -p /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.orig
 

root@nirav:~# vim /etc/vsftpd/vsftpd.conf
 

#Disable anonymous login
Comment the below line
#anonymous_enable=YES
OR
anonymous_enable=NO

 
#Enable the custom logs. By default, the xferlog file contains logging information from the FTP server daemon.
 

xferlog_std_format=NO
log_ftp_protocol=YES

  
# You may specify an explicit list of local users to chroot() to their home directory. If chroot_local_user is YES, then this list becomes a list of users to NOT chroot().
 

chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list


# When "listen" directive is enabled, vsftpd runs in standalone mode and listens on IPv4 sockets.
 

listen=YES 

# Disable listening on IPv6 sockets. By default, listening on the IPv6 "any" address (::) will accept connections from both IPv6 and IPv4 clients. 

listen_ipv6=NO 

#To configure passive mode for vsftpd you need to set some parameters
pasv_enable=YES
pasv_max_port=24200
pasv_min_port=24000
port_enable=YES
pasv_address=xxxx.xxxx.xxxx.xxxx ( Public or Elastic IP Address ) 

root@nirav:~# vim /etc/vsftpd/chroot_list
 

Add the lists of users you want to be chrooted to their directory.
nirav

 
root@nirav:~# systemctl enable vsftpd.service


 
root@nirav:~# systemctl start vsftpd.service

Friday, June 12, 2015

Disable GUI Root Login ( CentOS/RHEL 6.x )



Edit the file /etc/pam.d/gdm-password 

root@nirav:~# vim /etc/pam.d/gdm-password


These modules need to be set 

auth       required       pam_succeed_if.so user != root quiet

save and quit 

now root GUI login is disabled.

Restore Corrupted Bash Shell ( CentOS/RHEL 6.x )

nirav@nirav:~$ ssh root@192.168.0.202
root@192.168.0.202's password:


If you get a prompt like below

-bash-4.1#

Then there are copies of bash environment files in /etc/skel. /etc/skel directory contains files and directories that are added to the user's home directory whenever a new user is created. '.' indicates the files and directories inside are hidden.


So, copy the .bash_logout, .bash_profile, .bashrc files to your home directory.

-bash-4.1# cp /etc/skel/.bash* /root/
 

Press Ctrl+D to logout

-bash-4.1# logout
Connection to 192.168.0.202 closed.
 

nirav@nirav:~$ ssh root@192.168.0.202
root@192.168.0.202's password:


You will again get your bash shell

[root@desktop202 ~]#