您好,登錄后才能下訂單哦!
今天小編給大家分享一下Ubuntu環(huán)境下如何搭建FTP服務(wù)器的相關(guān)知識點,內(nèi)容詳細,邏輯清晰,相信大部分人都還太了解這方面的知識,所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。
安裝ftp
安裝ftp:
sudo apt-get update sudo apt-get install vsftpd
檢查ftp是否安裝:
vsftpd --version
更改配置文件
注意使用sudo命令獲得root權(quán)限
打開配置文件:
sudo vim /etc/vsftpd.conf
做如下更改:
# example config file /etc/vsftpd.conf # # the default compiled in settings are fairly paranoid. this sample file # loosens things up a bit, to make the ftp daemon more usable. # please see vsftpd.conf.5 for all compiled in defaults. # # read this: this example file is not an exhaustive list of vsftpd options. # please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's # capabilities. # # # run standalone? vsftpd can run either from an inetd or as a standalone # daemon started from an initscript. listen=no # # this directive enables listening on ipv6 sockets. by default, listening # on the ipv6 "any" address (::) will accept connections from both ipv6 # and ipv4 clients. it is not necessary to listen on *both* ipv4 and ipv6 # sockets. if you want that (perhaps because you want to listen on specific # addresses) then you must run two copies of vsftpd with two configuration # files. listen_ipv6=yes # # allow anonymous ftp? (disabled by default). anonymous_enable=no # # uncomment this to allow local users to log in. local_enable=yes # # uncomment this to enable any form of ftp write command. write_enable=yes # # default umask for local users is 077. you may wish to change this to 022, # if your users expect that (022 is used by most other ftpd's) local_umask=022 # # uncomment this to allow the anonymous ftp user to upload files. this only # has an effect if the above global write enable is activated. also, you will # obviously need to create a directory writable by the ftp user. #anon_upload_enable=yes # # uncomment this if you want the anonymous ftp user to be able to create # new directories. #anon_mkdir_write_enable=yes # # activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=yes # # if enabled, vsftpd will display directory listings with the time # in your local time zone. the default is to display gmt. the # times returned by the mdtm ftp command are also affected by this # option. use_localtime=yes # # activate logging of uploads/downloads. xferlog_enable=yes # # make sure port transfer connections originate from port 20 (ftp-data). connect_from_port_20=yes # # if you want, you can arrange for uploaded anonymous files to be owned by # a different user. note! using "root" for uploaded files is not # recommended! #chown_uploads=yes #chown_username=whoever # # you may override where the log file goes if you like. the default is shown # below. xferlog_file=/var/log/vsftpd.log # # if you want, you can have your log file in standard ftpd xferlog format. # note that the default log file location is /var/log/xferlog in this case. xferlog_std_format=yes # # you may change the default value for timing out an idle session. #idle_session_timeout=600 # # you may change the default value for timing out a data connection. #data_connection_timeout=120 # # it is recommended that you define on your system a unique user which the # ftp server can use as a totally isolated and unprivileged user. #nopriv_user=ftpsecure # # enable this and the server will recognise asynchronous abor requests. not # recommended for security (the code is non-trivial). not enabling it, # however, may confuse older ftp clients. #async_abor_enable=yes # # by default the server will pretend to allow ascii mode but in fact ignore # the request. turn on the below options to have the server actually do ascii # mangling on files when in ascii mode. # beware that on some ftp servers, ascii support allows a denial of service # attack (dos) via the command "size /big/file" in ascii mode. vsftpd # predicted this attack and has always been safe, reporting the size of the # raw file. # ascii mangling is a horrible feature of the protocol. #ascii_upload_enable=yes #ascii_download_enable=yes # # you may fully customise the login banner string: ftpd_banner=welcome to blah ftp service. # # you may specify a file of disallowed anonymous e-mail addresses. apparently # useful for combatting certain dos attacks. #deny_email_enable=yes # (default follows) #banned_email_file=/etc/vsftpd.banned_emails # # you may restrict local users to their home directories. see the faq for # the possible risks in this before using chroot_local_user or # chroot_list_enable below. #chroot_local_user=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(). # (warning! chroot'ing can be very dangerous. if using chroot, make sure that # the user does not have write access to the top level directory within the # chroot) chroot_local_user=yes chroot_list_enable=yes # (default follows) chroot_list_file=/etc/vsftpd.chroot_list # # you may activate the "-r" option to the builtin ls. this is disabled by # default to avoid remote users being able to cause excessive i/o on large # sites. however, some broken ftp clients such as "ncftp" and "mirror" assume # the presence of the "-r" option, so there is a strong case for enabling it. #ls_recurse_enable=yes # # customization # # some of vsftpd's settings don't fit the filesystem layout by # default. # # this option should be the name of a directory which is empty. also, the # directory should not be writable by the ftp user. this directory is used # as a secure chroot() jail at times vsftpd does not require filesystem # access. secure_chroot_dir=/var/run/vsftpd/empty # # this string is the name of the pam service vsftpd will use. pam_service_name=ftp # # this option specifies the location of the rsa certificate to use for ssl # encrypted connections. rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key ssl_enable=no # # uncomment this to indicate that vsftpd use a utf8 filesystem. utf8_filesystem=yes
退出編輯模式后,使用:wq保存退出vim.
創(chuàng)建ftp用戶
此處的操作需要使用root權(quán)限,若操作被拒絕,使用sudo:
sudo mkdir /home/ftpdir sudo useradd ftpdir -d /home/ftpdir -m sudo passwd ftpdir sudo mkdir /home/ftpdir/ftp sudo chmod 777 -r /home/ftpdir/ftp usermod -s /sbin/nologin ftpdir
配置完成后,添加用戶:
sudo vim /etc/vsftpd.chroot_list
將ftpdir添加在文件中。
ftpdir
到此為止,整個ftp的搭建過程就完成了,接下來就是關(guān)于如何去使用了。
啟動或者重啟ftp
啟動或者重啟ftp:
service vsftpd startservice vsftpd restart
查看ftp狀態(tài):
service vsftpd status
若要關(guān)閉ftp服務(wù),可以使用如下命令:
service vsftpd stop
查看服務(wù)器ip
打開命令端
robot@robot:~$ ifconfig enp4s0f2 link encap:ethernet hwaddr 74:d0:2b:ec:fa:f9 up broadcast multicast mtu:1500 metric:1 rx packets:0 errors:0 dropped:0 overruns:0 frame:0 tx packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 rx bytes:0 (0.0 b) tx bytes:0 (0.0 b) lo link encap:local loopback inet addr:127.0.0.1 mask:255.0.0.0 inet6 addr: ::1/128 scope:host up loopback running mtu:65536 metric:1 rx packets:12840 errors:0 dropped:0 overruns:0 frame:0 tx packets:12840 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 rx bytes:1174976 (1.1 mb) tx bytes:1174976 (1.1 mb) wlp3s0 link encap:ethernet hwaddr 24:fd:52:85:42:0c inet addr:192.168.1.110 bcast:192.168.1.255 mask:255.255.255.0 inet6 addr: fe80::c13c:b38e:69c7:cdf2/64 scope:link up broadcast running multicast mtu:1500 metric:1 rx packets:99764 errors:0 dropped:0 overruns:0 frame:0 tx packets:95225 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 rx bytes:98718687 (98.7 mb) tx bytes:14326894 (14.3 mb)
由于此處連接的是wifi,因此在wlp3s0這里找到對應(yīng)的ip地址為192.168.1.110(如果連接網(wǎng)線則在第一段找ip,每臺電腦的配置都不一樣,可根據(jù)實際情況考慮)
登陸
使用filezilla或者打開文件管理器輸入ftp://ipaddress
打開計算機,輸入服務(wù)器的ip地址
輸入用戶名和密碼,此處使用的用戶名為ftpdir
,密碼為123456
最后就可以看到服務(wù)器上的創(chuàng)建的文件夾了。
ubuntu上文件位置
在完成ftp服務(wù)器的搭建和測試工作后,文件存放在服務(wù)哪里呢,怎么找到這些文件?
在創(chuàng)建用戶那一節(jié),在/home
目錄這里創(chuàng)建了ftpdir
文件夾,ftpdir
文件夾里創(chuàng)建了一個可讀可寫的文件夾ftp
,在之后的文件傳輸中,可以切換到ftp
文件夾中尋找文件,此處操作需要使用sudo
獲取權(quán)限。
robot@robot:~$ cd /home/ftpdir/ftp robot@robot:/home/ftpdir/ftp$ ls 魔方.zip
以上就是“Ubuntu環(huán)境下如何搭建FTP服務(wù)器”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會為大家更新不同的知識,如果還想學(xué)習更多的知識,請關(guān)注億速云行業(yè)資訊頻道。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。