The establishment of FTP server based on UNIX platform

Source: Internet
Author: User
Tags anonymous exit chmod ftp mkdir

At present, many enterprise organizations are framing their own intranet,ftp server is one of the service support, a number of units to purchase a UNIX-based platform of computers, in order to be able to provide FTP service online support, specialized in the acquisition of Unix-based platform FTP server software, In fact, based on the UNIX platform of Computer systems, to take certain technical methods, you can set up their own FTP Server, to achieve online file download services, no need to purchase specialized software, and music and not for it? The following is an elaboration of its establishment process:

1, determine the FTP server's shared directory

Create an FTP working directory for FTP server, which is set to/home/ftp

2, write the FTP server initial settings of the shell program (Setup)

Use an editing tool (such as VI) to write a shell program to set up the system.

The following are the referenced contents:

#!/bin/sh

Case $# in

0) ftphome= "' grep ' ^ftp: '/etc/passwd | cut-d:-f6 ' "

;;

1 if ["$" = "start"]; Then

Ftphome= "' grep ' ^ftp: '/etc/passwd | cut-d:-f6 ' "

Else

Ftphome=$1

Fi

;;

*) echo "Usage: $ [Anon-ftp-root]"

Exit 1

;;

Esac

If [-Z "${ftphome}"]; Then

echo "$0:ftphome must be Non-null"

Exit 2

Fi

if ["${ftphome}" = "/"-O "${ftphome}" = "/usr"]; Then

echo "$0:ftphome must not BE/OR/USR"

Exit 2

Fi

if [!-D ${ftphome}]; Then

mkdir ${ftphome}

Fi

if [!-D ${ftphome}/usr/bin]; Then

Mkdir-p ${ftphome}/usr/bin

Fi

Cp/usr/bin/ls ${ftphome}/usr/bin

chmod ${ftphome}/usr/bin/ls

Chown Root ${ftphome}/usr/bin

chmod 555 ${ftphome}/usr/bin

If [R ${ftphome}/bin]; Then

Mv-f ${ftphome}/bin ${ftphome}/obin

Fi

Ln-s Usr/bin ${ftphome}

if [!-D ${ftphome}/usr/lib]; Then

Mkdir-p ${ftphome}/usr/lib

Fi

if [!-D ${FTPHOME}/ETC]; Then

Mkdir-p ${ftphome}/etc

Fi

Cp/usr/lib/ld.so/usr/lib/ld.so.1 ${ftphome}/usr/lib

For Lib in libc libdl libintl libw libnsl libsocket \

Nss_nis Nss_nisplus Nss_dns Nss_files

Todo

Cp/usr/lib/${lib}.so.1 ${ftphome}/usr/lib

Rm-f ${ftphome}/usr/lib/${lib}.so

Ln-s./${lib}.so.1 ${ftphome}/usr/lib/${lib}.so

Done


Cp/usr/lib/straddr.so.2 ${ftphome}/usr/lib

Rm-f ${ftphome}/usr/lib/straddr.so

Ln-s./straddr.so.2 ${ftphome}/usr/lib/straddr.so

Cp/etc/passwd/etc/group/etc/netconfig ${ftphome}/etc

chmod 555 ${ftphome}/usr/lib/*

chmod 444 ${ftphome}/etc/*

Chown Root ${ftphome}/usr/lib ${ftphome}/etc

chmod 555 ${ftphome}/usr/lib ${ftphome}/etc

if [!-D ${ftphome}/dev]; Then

Mkdir-p ${ftphome}/dev

Fi

prefix= "/devices/pseudo/mm@0:"

For device in Zero

Todo

Line= ' Ls-l ${prefix}${device} | Sed-e ' s/,//'

Major= ' echo $line | awk ' {print $} '

Minor= ' echo $line | awk ' {print $} '

Rm-f ${ftphome}/dev/${device}

Mknod ${ftphome}/dev/${device} C ${major} ${minor}

Done

prefix= " /devices/pseudo/clone@0: "

For device in TCP UDP Ticotsord

Todo

Line= ' Ls-l ${prefix}${device} | Sed-e ' s/,//'

Major= ' echo $line | awk ' {print $} '

Minor= ' echo $line | awk ' {print $} '

Rm-f ${ftphome}/dev/${device}

Mknod ${ftphome}/dev/${device} C ${major} ${minor}

Done

chmod 666 ${ftphome}/dev/*

Chown Root ${ftphome}/dev

chmod 555 ${ftphome}/dev

#建立一个匿名FTP服务目录, and set up readable writable properties

if [!-D ${ftphome}/pub]; Then

Mkdir-p ${ftphome}/pub

Fi

Chown FTP ${ftphome}/pub

chmod 777 ${ftphome}/pub

3. Edit/etc/passwd and/etc/shadow documents

To set up an anonymous FTP account, add the following data items to the/etc/passwd and/etc/shadow two files, respectively, in the following ways:

(1) Increase in the/etc/passwd file

Ftp:x:30000:30000:anonymous Ftp:/home/ftp:/nosuchshell

(2) Increase in the/etc/shadow file

ftp:np:6445:::::

4., run the Setup program

Before you run the Setup program, set the file as the execution file

#chmod +x Setup

Run the Setup program #setup/home/ftp

The above steps to complete the establishment of the FTP server, you can use the FTP server, such as Explorer, Netscape Navigator and other browsers to access the FTP server, download and upload file operations, the use of very convenient.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.