Create password file in linux

How to Setup Password Authentication with Apache in Ubuntu

To Setup Password Authentication with Apache in Ubuntu

Apache is a popular web server that hides the websites private information from unauthorized users. It provides easiest way to secure your site with free trusted certificates. This article shows how to setup password authentication with Apache in Ubuntu.

Installation of Apache

Utilize the following command to install Apache package.

[email protected]:~# apt-get install apache2 apache2-utils -y Reading package lists. Done Building dependency tree Reading state information. Done The following additional packages will be installed: apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 Suggested packages: apache2-doc apache2-suexec-pristine | apache2-suexec-custom The following NEW packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 0 upgraded, 9 newly installed, 0 to remove and 421 not upgraded. Need to get 1,537 kB of archives. After this operation, 6,350 kB of additional disk space will be used. Get:1 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libapr1 amd64 1.5.2-3 [86.0 kB] Get:2 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libaprutil1 amd64 1.5.4-1build1 [77.1 kB] Get:3 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libaprutil1-dbd-sqlite3 amd64 1.5.4-1build1 [10.6 kB] Get:4 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libaprutil1-ldap amd64 1.5.4-1build1 [8,720 B] Get:5 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 liblua5.1-0 amd64 5.1.5-8ubuntu1 [102 kB] Get:6 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 apache2-bin amd64 2.4.18-2ubuntu3.1 [923 kB] Get:7 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 apache2-utils amd64 2.4.18-2ubuntu3.1 [81.3 kB] Get:8 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 apache2-data all 2.4.18-2ubuntu3.1 [162 kB] Get:9 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 apache2 amd64 2.4.18-2ubuntu3.1 [86.7 kB] Fetched 1,537 kB in 29s (51.3 kB/s) Selecting previously unselected package libapr1:amd64. (Reading database . 173836 files and directories currently installed.) . . . Enabling conf localized-error-pages. Enabling conf other-vhosts-access-log. Enabling conf security. Enabling conf serve-cgi-bin. Enabling site 000-default. Processing triggers for libc-bin (2.23-0ubuntu3) . Processing triggers for ureadahead (0.100.0-19) . Processing triggers for systemd (229-4ubuntu4) . Processing triggers for ufw (0.35-0ubuntu2) .

To create password file

The ‘ htpasswd ‘ command allows you to create a password file. Here we will creating a hidden file .htpasswd within our /etc/apache2 configuration directory.

[email protected]:~# htpasswd -c /etc/apache2/.htpasswd user1 New password: Re-type new password: Adding password for user user1 [email protected]:~# htpasswd -c /etc/apache2/.htpasswd user2 New password: Re-type new password: Adding password for user user2

You can view the username and the encrypted password for each user.

[email protected]:~# cat /etc/apache2/.htpasswd user1:$apr1$d/XhO7Ko$/nyf1UGdWfaA0rQ17VVAT/

Now its time to configure Apache password authentication .

roo[email protected]:~# nano /etc/apache2/sites-enabled/000-default.conf < Directory " /var/www/html" >AuthType Basic AuthName " Restricted Content" AuthUserFile /etc/apache2/.htpasswd Require valid-user

Check the configuration, before restart it.

[email protected]:~# apache2ctl configtest Syntax OK

Restart the Apache to take effect and check the status.

[email protected]:~# systemctl restart apache2 [email protected]:~# systemctl status apache2 apache2.service - LSB: Apache2 web server Loaded: loaded (/etc/init.d/apache2 bad vendor preset: enabled) Drop-In: /lib/systemd/system/apache2.service.d ??apache2-systemd.conf Active: active (running) since Fri 2016-11-18 17:39:43 IST 18s ago Docs: man:systemd-sysv-generator(8) Process: 4476 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS) Process: 4501 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS) Tasks: 55 (limit: 512) CGroup: /system.slice/apache2.service ??4518 /usr/sbin/apache2 -k start ??4521 /usr/sbin/apache2 -k start ??4522 /usr/sbin/apache2 -k start Nov 18 17:39:42 linuxhelp1 systemd[1]: Starting LSB: Apache2 web server. Nov 18 17:39:42 linuxhelp1 apache2[4501]: * Starting Apache httpd web server apache2 Nov 18 17:39:43 linuxhelp1 apache2[4501]: * Nov 18 17:39:43 linuxhelp1 systemd[1]: Started LSB: Apache2 web server.

Utilize the following command for access control with the .htaccess Files.

[email protected]:~# nano /etc/apache2/apache2.conf Options Indexes FollowSymLinks AllowOverride All Require all granted

Here you need to add .htaccess file to the directory to restrict the entire document root.

[email protected]:~# nano /var/www/html/.htaccess AuthType Basic AuthName " Restricted Content" AuthUserFile /etc/apache2/.htpasswd Require valid-user

Restart the web server to take effect and check the status for verification.

[email protected]:~# systemctl restart apache2 [email protected]:~# systemctl status apache2 apache2.service - LSB: Apache2 web server Loaded: loaded (/etc/init.d/apache2 bad vendor preset: enabled) Drop-In: /lib/systemd/system/apache2.service.d ??apache2-systemd.conf Active: active (running) since Fri 2016-11-18 17:43:58 IST 17s ago Docs: man:systemd-sysv-generator(8) Process: 4630 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS) Process: 4655 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS) Tasks: 55 (limit: 512) CGroup: /system.slice/apache2.service ??4672 /usr/sbin/apache2 -k start ??4675 /usr/sbin/apache2 -k start ??4676 /usr/sbin/apache2 -k start Nov 18 17:43:57 linuxhelp1 systemd[1]: Starting LSB: Apache2 web server. Nov 18 17:43:57 linuxhelp1 apache2[4655]: * Starting Apache httpd web server apache2 Nov 18 17:43:58 linuxhelp1 apache2[4655]: * Nov 18 17:43:58 linuxhelp1 systemd[1]: Started LSB: Apache2 web server.

Once the above process is completed, lets try to access the restricted content in a web browser as shown below,

Читайте также:  Com ports on linux

Apache-password-authentication-open-web-browser

Enter the following credentials.

Apache-password-authentication-user-credentials

Apache default page appears.

Apache-password-authentication-default-page

Again enter the same IP address.

Apache-password-authentication-IP

If you are not giving the respective credentials, then it will display the output as shown below,

Источник

How to Create a Password Protected Zip File in Linux

This simple tutorial shows you how to create a password protected zip file in Linux both in command line and graphical way.

  • Create password protected zip file in Linux command line
  • Create password protected zip file using Nautilus file manager [GUI method]

There are several ways you can encrypt zip file in Linux. There are dedicated command line tools for this task, but I am not going to talk about those. I will show you how to password protect a zip file without installing a dedicated tool.

Create password protect zip file in Linux command line

First thing first, make sure that you have zip support enabled in your Linux system. Use your distribution’s package manager and try to install it. If its not installed already, it will be installed.

In Debian/Ubuntu, you can use this command:

sudo apt install zip unzip

Now, let’s see how to password protect a zip file in Linux. The method is almost the same as creating zip folder in Linux. The only difference is the use of option -e for encryption.

zip -re output_file.zip file1 folder1

The -r option is used to recursively look into directories. The -e option is for encryption.

You’ll be asked to enter and verify the password. You won’t see the password being typed on the screen, that’s normal. Just type the password and press enter both times.

Читайте также:  Посмотреть pid процесса linux

Here’s what the process looks like on the screen:

zip -re my_zip_folder.zip agatha.txt cpluplus.cpp test_dir Enter password: Verify password: adding: agatha.txt (deflated 41%) adding: cpluplus.cpp (deflated 4%) adding: test_dir/ (stored 0%) adding: test_dir/myzip1.zip (stored 0%) adding: test_dir/myzip2.zip (stored 0%) adding: test_dir/c.xyz (stored 0%)

Do note that if someone tries to unzip this file, he/she can see the content of the folder such as which files are there in the zipped file. But the files cannot be read.

Create a password protected zip file in Linux using GUI

I have created a password-protected zip file in Ubuntu 18.04 here but you can use the same steps on any Linux distribution with GNOME desktop environment.

Search for Archive Manager and open it.

Archive Manager Ubuntu

Drag and drop the file(s) you want to compress into a zip file. Select Create Archive option here.

Create Archive Ubuntu 1

In here, choose the type of compressed file. It will be .zip in my case. You’ll see the “Other Options”, click on it and you’ll see the password field. Enter the password you want and click on the Save button.

Creating Password Protected Zip file in Ubuntu Linux

That’s it. You have successfully created a password protected zip file in Ubuntu Linux graphically. The next time you want to extract it, it will ask for a password.

Password Protected Zip file in Ubuntu

As you can see, no one (in normal ways) can extract this file without the password. Congratulations, you just learned how to encrypt zip files in Ubuntu Linux.

Just for your information, double-clicking on the password-protected directory might give the impression that you may access the encrypted directory without a password, but you cannot actually read those files.

Читайте также:  System configuration tools in linux

There are other ways to password protect folders in Linux. This tutorial shows how to do that.

I hope this quick tutorial helped you to create password-protected zip files in Linux.

Источник

How to Create a Password Protected ZIP File in Linux

ZIP is a very popular compression and file packaging utility for Unix-like operating systems as well as Windows. While perusing through the zip man page, I discovered some useful options for protecting zip archives.

In this post, I will show you how to create a password protected zip file on the terminal in Linux. This will help you learn a practical way of encrypting and decrypting contents of zip archive files.

First install zip utility in your Linux distribution using the package manger as shown.

$ sudo yum install zip [On CentOS/RHEL] $ sudo dnf install zip [On Fedora 22+] $ sudo apt install zip [On Debian/Ubuntu]

How to Create Password Protected ZIP in Linux

Once installed, you can use the zip command with -p flag to create a password protected zip archive called ccat-command.zip from the directory of files called ccat-1.1.0 as follows.

$ zip -p pass123 ccat-command.zip ccat-1.1.0/

Create Password Protected Zip File

However, the above method is absolutely insecure, because here the password is provided as clear-text on the command line. Secondly, it will also be stored in the history file (e.g ~.bash_history for bash), meaning another user with access to your account (more especially root user) will easily see the password.

Therefore, try to always use the -e flag, it shows a prompt allowing you to enter a hidden password as shown.

$ zip -e ccat-command.zip ccat-1.1.0/

Create Password Protect Zip Archive

How to Unzip Password Protected ZIP in Linux

To unzip and decrypt the content of the archive file called ccat-command.zip, use the unzip program and provide the password you entered above.

Decrypt ZIP Archive

That’s It! In this post, I described how to create a password protected zip file on the terminal in Linux. If you have any queries, or other useful related tip/tricks to share, use the comment form below ping us.

Источник

Оцените статью
Adblock
detector