计算机摘录

Multisite Drupal

Download the latest Drupal Code base.
Then, upload and extract all the files into a new folder for Drupal. For example: /public_html/drupal/

Next step 
In this example i'll be creating two websites
test1.localhost.com
and 
test2.localhost.com

I Will be needing two database for two sites
test1_db

test2_db

Next step is to inform drupal about our need for multisite. 
So we need to add the sites.php file.
You can find extra examples and documentation of how to set it up in the example.sites.php file.

Copy the file and rename it to sites.php
add the following lines to configure the above sites

$sites['test1.localhost.com'] = 'test1.localhost.com';

$sites['test2.localhost.com'] = 'test2.localhost.com';

Next step will be:
In /drupal/sites  create the following folders 
test1.localhost.com
test2.localhost.com

After above configurations (copy sites/default/example.settings.php into  sites/subsite/settings.php and edit it) you need to install both the site using url below and then after installation you can access your multi site feature.

test1.localhost.com/core/install.php

test2.localhost.com/core/install.php

You can find more info on multisite in core/INSTALL.txt.


健康原创

美国康涅狄格大学的化学教授研究出一个叫“AH10-7 ”的化合物--能活化iNKT免疫细胞,阻止肿瘤生长和扩散--炸药也是化学,漂染也是化学……


健康原创

纽约石溪大学医院给10位病人植入--美敦力公司生产的,世界最小的心脏起博器 (1.01英寸)--石溪,不是石狮哦。


健康原创

哈佛公共卫生学院说,经常吃高温烹饪(如烧烤等)食物--除了增加得肿瘤的风险,也增加患2型糖尿病的风险--少吃烧烤,少吃油炸食物。


健康原创

美國防一研究署和德克萨斯大学西南医学中心研究--让电子信号与神经“相通”,使机器假肢有“感觉”--据说新型假肢3年内可上市,科幻的时代来了。


健康原创

斯坦福大学研究发现,给18位轻~中度老年痴呆症患者输入年轻人(18-30岁)的血浆--可提升患者的日常生活能力,他们将扩大实验范围--血浆需要输入,直接喝没用哦。


健康原创

包括耶鲁、斯坦福等40多家医疗集团加入苹果公司的Health Recode, 健康记录系统--病人可以用Iphone 查询自己的医疗历史记录--苹果卖的不只是手机呀


健康原创

拉什大学医学院说,服用他汀类降脂药,不能喝葡萄汁--会增加他汀类药对关节和肾负作用--告诉你身边吃他汀药的人吧。

,

计算机摘录

 

https://www.digitalocean.com/community/tutorials/how-to-set-up-vsftpd-for-a-user-s-directory-on-ubuntu-16-04

Introduction

 

In this tutorial, we'll show you how to configure vsftpd to allow a user to upload files to his or her home directory using FTP with login credentials secured by SSL/TLS.

Prerequisites

To follow along with this tutorial you will need:

  • An Ubuntu 16.04 server with a non-root user with sudo privileges:

Once you have an Ubuntu server in place, you're ready to begin.

Step 1 — Installing vsftpd

We'll start by updating our package list and installing the vsftpd daemon:

  • sudo apt-get update
  •  
  • sudo apt-get install vsftpd

When the installation is complete, we'll copy the configuration file so we can start with a blank configuration, saving the original as a backup.

  • sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.orig
  •  

With a backup of the configuration in place, we're ready to configure the firewall.

Step 2 — Opening the Firewall

We'll check the firewall status to see if it’s enabled. If so, we’ll ensure that FTP traffic is permitted so you won’t run into firewall rules blocking you when it comes time to test.

  • sudo ufw status
  •  

In this case, only SSH is allowed through:

Output

Status: active

 

To Action  From

-- ------  ----

OpenSSH ALLOW   Anywhere

OpenSSH (v6)   ALLOW   Anywhere (v6)

You may have other rules in place or no firewall rules at all. Since only ssh traffic is permitted in this case, we’ll need to add rules for FTP traffic.

We'll need to open ports 20 and 21 for FTP, port 990 for later when we enable TLS, and ports 40000-50000 for the range of passive ports we plan to set in the configuration file:

  • sudo ufw allow 20/tcp
  •  
  • sudo ufw allow 21/tcp
  •  
  • sudo ufw allow 990/tcp
  •  
  • sudo ufw allow 40000:50000/tcp
  •  
  • sudo ufw status
  •  

Now our firewall rules looks like:

Output

Status: active

 

To                         Action      From

--                         ------      ----

OpenSSH                    ALLOW       Anywhere

990/tcp                    ALLOW       Anywhere

20/tcp                     ALLOW       Anywhere

21/tcp                     ALLOW       Anywhere

40000:50000/tcp            ALLOW       Anywhere

OpenSSH (v6)               ALLOW       Anywhere (v6)

20/tcp (v6)                ALLOW       Anywhere (v6)

21/tcp (v6)                ALLOW       Anywhere (v6)

990/tcp (v6)               ALLOW       Anywhere (v6)

40000:50000/tcp (v6)       ALLOW       Anywhere (v6)

With vsftpd installed and the necessary ports open, we're ready to proceed to the next step.

Step 3 — Preparing the User Directory

For this tutorial, we're going to create a user, but you may already have a user in need of FTP access. We'll take care to preserve an existing user’s access to their data in the instructions that follow. Even so, we recommend you start with a new user until you've configured and tested your setup.

First, we’ll add a test user:

  • sudo adduser sammy
  •  

Assign a password when prompted and feel free to press "ENTER" through the other prompts.

FTP is generally more secure when users are restricted to a specific directory.vsftpd accomplishes this with chroot jails. When chroot is enabled for local users, they are restricted to their home directory by default. However, because of the way vsftpd secures the directory, it must not be writable by the user. This is fine for a new user who should only connect via FTP, but an existing user may need to write to their home folder if they also shell access.

In this example, rather than removing write privileges from the home directory, we're will create an ftpdirectory to serve as the chroot and a writable files directory to hold the actual files.

Create the ftp folder, set its ownership, and be sure to remove write permissions with the following commands:

  • sudo mkdir /home/sammy/ftp
  •  
  • sudo chown nobody:nogroup /home/sammy/ftp
  •  
  • sudo chmod a-w /home/sammy/ftp
  •  

Let's verify the permissions:

  • sudo ls -la /home/sammy/ftp
  •  

Output

total 8

4 dr-xr-xr-x  2 nobody nogroup 4096 Aug 24 21:29 .

4 drwxr-xr-x 3 sammy  sammy   4096 Aug 24 21:29 ..

Next, we'll create the directory where files can be uploaded and assign ownership to the user:

  • sudo mkdir /home/sammy/ftp/files
  •  
  • sudo chown sammy:sammy /home/sammy/ftp/files
  •  

A permissions check on the files directory should return the following:

  • sudo ls -la /home/sammy/ftp
  •  

Output

total 12

dr-xr-xr-x 3 nobody nogroup 4096 Aug 26 14:01 .

drwxr-xr-x 3 sammy  sammy   4096 Aug 26 13:59 ..

drwxr-xr-x 2 sammy  sammy   4096 Aug 26 14:01 files

Finally, we'll add a test.txt file to use when we test later on:

  • echo "vsftpd test file" | sudo tee /home/sammy/ftp/files/test.txt
  •  

Now that we've secured the ftp directory and allowed the user access to the files directory, we'll turn our attention to configuration.

Step 4 — Configuring FTP Access

We're planning to allow a single user with a local shell account to connect with FTP. The two key settings for this are already set in vsftpd.conf. Start by opening the config file to verify that the settings in your configuration match those below:

  • sudo nano /etc/vsftpd.conf
  •  

/etc/vsftpd.conf

. . .

# Allow anonymous FTP? (Disabled by default).

anonymous_enable=NO

#

# Uncomment this to allow local users to log in.

local_enable=YES

. . .

Next we'll need to change some values in the file. In order to allow the user to upload files, we’ll uncomment the write_enable setting so that we have:

/etc/vsftpd.conf

. . .

write_enable=YES

. . .

We’ll also uncomment the chroot to prevent the FTP-connected user from accessing any files or commands outside the directory tree.

/etc/vsftpd.conf

. . .

chroot_local_user=YES

. . .

We’ll add a user_sub_token in order to insert the username in our local_root directory path so our configuration will work for this user and any future users that might be added.

/etc/vsftpd.conf

user_sub_token=$USER

local_root=/home/$USER/ftp

We'll limit the range of ports that can be used for passive FTP to make sure enough connections are available:

/etc/vsftpd.conf

pasv_min_port=40000

pasv_max_port=50000

Note: We pre-opened the ports that we set here for the passive port range. If you change the values, be sure to update your firewall settings.
 

We will also add a directive telling vsftpd to listen on a particular port for incoming FTP connections:

/etc/vsftpd.conf

listen_port=45000

Since we’re only planning to allow FTP access on a case-by-case basis, we’ll set up the configuration so that access is given to a user only when they are explicitly added to a list rather than by default:

/etc/vsftpd.conf

userlist_enable=YES

userlist_file=/etc/vsftpd.userlist

userlist_deny=NO

userlist_deny toggles the logic. When it is set to "YES", users on the list are denied FTP access. When it is set to "NO", only users on the list are allowed access. When you're done making the change, save and exit the file.

Finally, we’ll create and add our user to the file. We'll use the -a flag to append to file:

  • echo "sammy" | sudo tee -a /etc/vsftpd.userlist
  •  

Double-check that it was added as you expected:

cat /etc/vsftpd.userlist

Output

sammy

Restart the daemon to load the configuration changes:

  • sudo systemctl restart vsftpd
  •  

Now we're ready for testing.

Step 5 — Testing FTP Access

We've configured the server to allow only the user sammy to connect via FTP. Let's make sure that's the case.

Anonymous users should fail to connect: We disabled anonymous access. Here we'll test that by trying to connect anonymously. If we've done it properly, anonymous users should be denied permission:

  • ftp -p 203.0.113.0
  •  

Output

Connected to 203.0.113.0.

220 (vsFTPd 3.0.3)

Name (203.0.113.0:default): anonymous

530 Permission denied.

ftp: Login failed.

ftp>

Close the connection:

  • bye
  •  

Users other than sammy should fail to connect: Next, we'll try connecting as our sudo user. They, too, should be denied access, and it should happen before they're allowed to enter their password.

  • ftp -p 203.0.113.0
  •  

Output

Connected to 203.0.113.0.

220 (vsFTPd 3.0.3)

Name (203.0.113.0:default): sudo_user

530 Permission denied.

ftp: Login failed.

ftp>

Close the connection:

  • bye
  •  

sammy should be able to connect, as well as read and write files: Here, we'll make sure that our designated user canconnect:

  • ftp -p 203.0.113.0
  •  

Output

Connected to 203.0.113.0.

220 (vsFTPd 3.0.3)

Name (203.0.113.0:default): sammy

331 Please specify the password.

Password: your_user's_password

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp>

We'll change into the files directory, then use the get command to transfer the test file we created earlier to our local machine:

  • cd files
  •  
  • get test.txt
  •  

Output

227 Entering Passive Mode (203,0,113,0,169,12).

150 Opening BINARY mode data connection for test.txt (16 bytes).

226 Transfer complete.

16 bytes received in 0.0101 seconds (1588 bytes/s)

ftp>

We'll turn right back around and try to upload the file with a new name to test write permissions:

  • put test.txt upload.txt
  •  

Output

227 Entering Passive Mode (203,0,113,0,164,71).

150 Ok to send data.

226 Transfer complete.

16 bytes sent in 0.000894 seconds (17897 bytes/s)

Close the connection:

  • bye
  •  

Now that we've tested our configuration, we'll take steps to further secure our server.

Step 6 — Securing Transactions

Since FTP does not encrypt any data in transit, including user credentials, we'll enable TTL/SSL to provide that encryption. The first step is to create the SSL certificates for use with vsftpd.

We'll use openssl to create a new certificate and use the -days flag to make it valid for one year. In the same command, we'll add a private 2048-bit RSA key. Then by setting both the -keyout and -out flags to the same value, the private key and the certificate will be located in the same file.

We'll do this with the following command:

  • sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem
  •  

You'll be prompted to provide address information for your certificate. Substitute your own information for the questions below:

Output

Generating a 2048 bit RSA private key

............................................................................+++

...........+++

writing new private key to '/etc/ssl/private/vsftpd.pem'

-----

You are about to be asked to enter information that will be incorporated

into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN.

There are quite a few fields but you can leave some blank

For some fields there will be a default value,

If you enter '.', the field will be left blank.

-----

Country Name (2 letter code) [AU]:US

State or Province Name (full name) [Some-State]:NY

Locality Name (eg, city) []:New York City

Organization Name (eg, company) [Internet Widgits Pty Ltd]:DigitalOcean

Organizational Unit Name (eg, section) []:

Common Name (e.g. server FQDN or YOUR name) []: your_IP_address

Email Address []:

For more detailed information about the certificate flags, see OpenSSL Essentials: Working with SSL Certificates, Private Keys and CSRs

Once you've created the certificates, open the vsftpd configuration file again:

  • sudo nano /etc/vsftpd.conf
  •  

Toward the bottom of the file, you should two lines that begin with rsa_. Comment them out so they look like:

/etc/vsftpd.conf

# rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem

# rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

 

Below them, add the following lines which point to the certificate and private key we just created:

/etc/vsftpd.conf

rsa_cert_file=/etc/ssl/private/vsftpd.pem

rsa_private_key_file=/etc/ssl/private/vsftpd.pem

After that, we will force the use of SSL, which will prevent clients that can't deal with TLS from connecting. This is necessary in order to ensure all traffic is encrypted but may force your FTP user to change clients. Change ssl_enable to YES:

/etc/vsftpd.conf

ssl_enable=YES

After that, add the following lines to explicitly deny anonymous connections over SSL and to require SSL for both data transfer and logins:

/etc/vsftpd.conf

allow_anon_ssl=NO

force_local_data_ssl=YES

force_local_logins_ssl=YES

After this we'll configure the server to use TLS, the preferred successor to SSL by adding the following lines:

/etc/vsftpd.conf

ssl_tlsv1=YES

ssl_sslv2=NO

ssl_sslv3=NO

Finally, we will add two more options. First, we will not require SSL reuse because it can break many FTP clients. We will require "high" encryption cipher suites, which currently means key lengths equal to or greater than 128 bits:

/etc/vsftpd.conf

require_ssl_reuse=NO

ssl_ciphers=HIGH

When you're done, save and close the file.

Now, we need to restart the server for the changes to take effect:

  • sudo systemctl restart vsftpd
  •  

At this point, we will no longer be able to connect with an insecure command-line client. If we tried, we'd see something like:

  • ftp -p 203.0.113.0
  •  
  • Connected to 203.0.113.0.
  •  
  • 220 (vsFTPd 3.0.3)
  •  
  • Name (203.0.113.0:default): sammy
  •  
  • 530 Non-anonymous sessions must use encryption.
  •  
  • ftp: Login failed.
  •  
  • 421 Service not available, remote server has closed connection
  •  
  • ftp>

 


健康原创

瑞士联邦水科学和技术研究所、苏黎世联邦理工学院和、美国伊利诺伊大学说--黄小鸭是细菌的天堂--鸭子吸水养细菌,小孩再挤手里,嘴里玩。玩具要常清洗,常晒太阳。

,

Subscribe to Home