Wednesday, May 1, 2013

Disable and Enable users in Linux

Disable and Enable a user account in Linux :
 
Prevent user to access account / Prevent user to reach on shell prompt :

If you want to disable a user account in Linux, follow these steps.

if it is debian or ubuntu :
$ sudo usermod -s /usr/sbin/nologin username
if it is centos or fedora :
$ sudo usermod -s /sbin/nologin username

When you try to access disabled account, it says
This account is currently not available

Second Method : 
a) Open file /etc/passwd and search your username there.
b) If a line ends with /bin/bash, it means user can log in.
c) Change the text  /bin/bash  into /sbin/nologin (centos or fedora) or /usr/sbin/nologin (debian or ubuntufor your username.
d) Save the file. Now User will not be able to log-in.



Enable a User Account
Allow user to access account / Allow user to reach on shell prompt :

If you want to enable a user account in Linux, Run the command.
$ sudo chsh -s /bin/bash username

Second Method : 
a) Open file /etc/passwd and search your username there.
b) If a line ends with /sbin/nologin (centos or fedora) or /usr/sbin/nologin (debian or ubuntu), it means user can not log in.
c) Change the text /sbin/nologin (centos or fedora) or /usr/sbin/nologin (debian or ubuntuinto  /bin/bash  for your username.
d) Save the file. Now User will be able to log-in.

You can see the solution in the following video.



Saturday, April 27, 2013

Disable ftp account of a specific user

If you want to disable ftp account of any user, you should follow these steps.

The process does not prevent user to log into shell prompt. User can log into shell prompt as well as execute the commands but he can't use ftp services.

If you are using debian or ubuntu. Run following command.
$ echo username >> /etc/ftpusers
If you are using centos or fedora. Run following command.
$ echo username >> /etc/vsftpd/ftpusers
The user will not be able to access ftp account.

If you do not want to use command line. Open file /etc/ftpusers or /etc/vsftpd/ftpusers (according to your distribution) and add username in the list.
To Allow access :
Just remove the username from the file ftpusers.
Restart vsftpd.

Enable ftp account of root

By Default, root is not able to access ftp because it's name in the list of /etc/ftpusers or /etc/vsftpd/ftpusers
Remove root from the list.
Restart vsftpd.
root will be able to log-in using ftp.

If you are using CentOS, fedora or RHEL and still you are not able to log in as root in your ftp server.
Add following line in the file vsftpd.conf
userlist_deny=YES
Remove user root fin the file /etc/vsftpd/user_list and restart vsftpd.
root should be able to log-in using ftp.

Tuesday, April 23, 2013

Install webmin on Linux - CentOS, Fedora, Debian or Ubuntu

Download webmin from here.

1) If your Linux distribution is yum based like CentOS or fedora,
Download rpm file of webmin and install it using 
$ sudo rpm -ivh webmin-installation-filename.rpm
If your Linux distribution is dpkg(deb) based like ubuntu or debian,
Download deb file of webmin and install it using 
$ sudo dpkg -i webmin-installation-filename.deb

2) Now webmin is installed and we can access it using port 10000, Open it.
https://localhost:10000

3) If your firewall prevents to access webmin using other system of same LAN, you should define port 10000 in iptables.
Add following line in /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10000 -j ACCEPT

4) Restart iptables
$ sudo service iptables restart

5) Now you can access it using
https://ip-of-the-server:10000

6) username, password of webmin is same as root's username & root's password of the server.


webmin - Security Warning

Warning! Webmin has detected that the program 
https://IP-address:10000/right.cgi?open=system&open=status was linked to from an unknown URL, which appears to be outside the Webmin server. This may be an attempt to trick your server into executing a dangerous command.

First Method :
  • Login as root, and edit the /etc/webmin/config file.
  • Find the line referers_none=1 and change it to referers_none=0.
  • Save the file.
Second Method :
  • Login to Webmin normally.
  • Go to the Webmin Configuration module.
  • Click on the Trusted Referrers icon.
  • Check the Trust links from unknown referrers box, and click Save.
Final Method :
If above both methods do not work, follow this.
Open following link in chrome
Select radio button NO for Referrer checking enabled?
Now try again.

webmin - Error - Bad Request

Open webmin url with https
The correct url is https://localhost:10000/webmin