从今天起,告别windows,投入ubuntu 16.04的怀抱

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#91

帖子 vickycq » 2016-01-25 11:11

按88楼修改配置后 没有 “重启 vsftpd,再尝试上传”,再查看 /var/log/vsftpd.log 和 /var/log/xferlog?
楼上的日志中没有新的上传信息

另问题无非是88楼的两个。先完全禁用 ufw 试试。

代码: 全选

sudo ufw disable
如果问题出在防火墙,再启用并细致调整

UFW 配置 参考
https://wiki.ubuntu.com/UncomplicatedFirewall
https://help.ubuntu.com/community/UFW
https://wiki.archlinux.org/index.php/Un ... d_Firewall
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
montana
帖子: 103
注册时间: 2007-08-11 15:56
系统: Ubuntu 16.04

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#92

帖子 montana » 2016-01-25 12:27

考虑到曾经修改过/home, /home/montana/www的权限,不知道是不是这个原因。

删除了www目录,重新建立了一个,又可以用ftp连接上了,可以下载,还是无法上传。此时,ufw是关闭的。
montana
帖子: 103
注册时间: 2007-08-11 15:56
系统: Ubuntu 16.04

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#93

帖子 montana » 2016-01-25 13:34

无法上传,vsftpd.log显示:

代码: 全选

Mon Jan 25 13:32:16 2016 [pid 2569] FTP response: Client "::ffff:192.168.1.2", "220 Welcome to Michael's FTP service."
Mon Jan 25 13:32:19 2016 [pid 2569] FTP command: Client "::ffff:192.168.1.2", "USER michael"
Mon Jan 25 13:32:19 2016 [pid 2569] [michael] FTP response: Client "::ffff:192.168.1.2", "331 Please specify the password."
Mon Jan 25 13:32:21 2016 [pid 2569] [michael] FTP command: Client "::ffff:192.168.1.2", "PASS <password>"
Mon Jan 25 13:32:21 2016 [pid 2568] [michael] OK LOGIN: Client "::ffff:192.168.1.2"
Mon Jan 25 13:32:21 2016 [pid 2572] [michael] FTP response: Client "::ffff:192.168.1.2", "230 Login successful."
Mon Jan 25 13:32:22 2016 [pid 2572] [michael] FTP command: Client "::ffff:192.168.1.2", "PORT 192,168,1,2,199,156"
Mon Jan 25 13:32:22 2016 [pid 2572] [michael] FTP response: Client "::ffff:192.168.1.2", "200 PORT command successful. Consider using PASV."
Mon Jan 25 13:32:22 2016 [pid 2572] [michael] FTP command: Client "::ffff:192.168.1.2", "NLST"
Mon Jan 25 13:32:22 2016 [pid 2572] [michael] FTP response: Client "::ffff:192.168.1.2", "150 Here comes the directory listing."
Mon Jan 25 13:32:22 2016 [pid 2572] [michael] FTP response: Client "::ffff:192.168.1.2", "226 Directory send OK."
Mon Jan 25 13:32:32 2016 [pid 2572] [michael] FTP command: Client "::ffff:192.168.1.2", "PORT 192,168,1,2,199,171"
Mon Jan 25 13:32:32 2016 [pid 2572] [michael] FTP response: Client "::ffff:192.168.1.2", "200 PORT command successful. Consider using PASV."
Mon Jan 25 13:32:32 2016 [pid 2572] [michael] FTP command: Client "::ffff:192.168.1.2", "STOR index2.html"
Mon Jan 25 13:32:32 2016 [pid 2572] [michael] FTP response: Client "::ffff:192.168.1.2", "553 Could not create file."
Mon Jan 25 13:32:32 2016 1 ::ffff:192.168.1.2 0 /index2.html a _ i r michael ftp 0 * i
Mon Jan 25 13:32:32 2016 [pid 2572] [michael] FAIL UPLOAD: Client "::ffff:192.168.1.2", "/index2.html", 0.00Kbyte/sec
montana
帖子: 103
注册时间: 2007-08-11 15:56
系统: Ubuntu 16.04

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#94

帖子 montana » 2016-01-25 13:36

xferlog里面一点信息也没有。
montana
帖子: 103
注册时间: 2007-08-11 15:56
系统: Ubuntu 16.04

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#95

帖子 montana » 2016-01-25 15:28

糊里糊涂的解决了。方法如下:

http://www.cnblogs.com/taoweiji/p/3821924.html

代码: 全选

增加一个ftpgroup用户组
sudo groupadd ftpgroup
增加用户ftpuser并设置其目录为/home/montana/www/ftpuser
sudo useradd -g ftpgroup -d /home/montana/www/ftpuser -M ftpuser
montana
帖子: 103
注册时间: 2007-08-11 15:56
系统: Ubuntu 16.04

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#96

帖子 montana » 2016-01-25 16:05

部分搞定,mark一下:

1. 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=YES
#
# 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=NO
#
# 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 Michael's 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
# vsftpd.chroot_list should include the list to be chrooted.

# 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

#根目录位置
local_root=/home/montana/ftpuser
pasv_promiscuous=YES
dual_log_enable=YES
log_ftp_protocol=YES

allow_writeable_chroot=YES
2. 增加一个ftpgroup用户组
sudo groupadd ftpgroup

3. 增加用户ftpuser并设置其目录为/home/montana/ftpuser/www(可以修改,但是必须创建该文件夹)

sudo useradd -g ftpgroup -d /home/montana/ftpuser/www -M ftpuser
如果上面的/home/montana/ftpuser/www没有被创建,即需要创建该文件夹
用户必须拥有权限才可以访问,赋予访问/home/montana/ftpuser/www的权限
sudo chmod 777 /home/montana/ftpuser/www

4. 设置ftpuser密码:
sudo passwd ftpuser
重启vsftpd:
sudo service vsftpd restart

5. 至此,可以实现对www目录的上传、下载。奇怪的是无法设置对ftpuser目录的上传下载,一旦设置777权限,会提示出错。

感谢vickycq兄的耐心指导。
上次由 montana 在 2016-02-02 23:00,总共编辑 4 次。
montana
帖子: 103
注册时间: 2007-08-11 15:56
系统: Ubuntu 16.04

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#97

帖子 montana » 2016-01-25 17:44

新问题来了,此时客户端上传的文件,比如index.html文件,在服务器上用浏览器却无法打开,图标显示加了一把小锁。设想通过ftp客户端远程传输html文件到服务器目录随时可以预览,不过这样的话要想每次传输上去的文件可读,就必须要来一下sudo chmod -R 777 xxx了。
这个问题该怎么解决呢?求助各位兄弟了。
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#98

帖子 vickycq » 2016-01-25 20:16

montana 写了:比如index.html文件,在服务器上用浏览器却无法打开,图标显示加了一把小锁。
貌似 vsftpd 默认本地用户 umask 为 077,这样其它用户不可读?
可以设置为 022 试试
/etc/vsftpd.conf 写了:# Default umask for local users is 077. You may wish to change this to 022

代码: 全选

local_umask=022
apache2 默认应该以 www-data 身份运行。
另外貌似还与 file_open_mode 和 chmod_enable 这两个参数有关,具体没研究。
另外貌似还需将本地用户加入 www-data 组?不确定。

参考
http://ubuntuforums.org/showthread.php?t=1436738
http://serverfault.com/questions/201305 ... via-vsftpd
http://serverfault.com/questions/571289 ... ot-working
https://wiki.apache.org/httpd/FileSystemPermissions
http://www.linuxquestions.org/questions ... on-168393/
http://tosbourn.com/changing-upload-per ... in-vsftpd/
http://superuser.com/questions/441515/h ... -mode-work
https://www.centos.org/forums/viewtopic.php?t=28067
http://serverfault.com/questions/357108 ... -webserver
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
montana
帖子: 103
注册时间: 2007-08-11 15:56
系统: Ubuntu 16.04

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#99

帖子 montana » 2016-01-25 20:37

代码: 全选

2. 增加一个ftpgroup用户组
sudo groupadd ftpgroup

3. 增加用户ftpuser并设置其目录为/home/montana/ftpuser/www(可以修改,但是必须创建该文件夹)
sudo useradd -g ftpgroup -d /home/montana/ftpuser/www -M ftpuser
这两步不是添加了一个ftpuser的ftp登录账号,貌似添加了一个登录系统的账号。方向似乎弄错了,重来!
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#100

帖子 vickycq » 2016-01-25 20:39

montana 写了: 这两步不是添加了一个ftpuser的ftp登录账号,貌似添加了一个登录系统的账号。方向似乎弄错了,重来!
不必重来,这样就很好。新建系统用户专门用于 ftp。
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
montana
帖子: 103
注册时间: 2007-08-11 15:56
系统: Ubuntu 16.04

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#101

帖子 montana » 2016-01-25 22:44

vickycq 写了:
montana 写了: 这两步不是添加了一个ftpuser的ftp登录账号,貌似添加了一个登录系统的账号。方向似乎弄错了,重来!
不必重来,这样就很好。新建系统用户专门用于 ftp。
好主意,这样不会弄混了。

新的发现,比如假定ftp根目录为/home/montana/ftpuser,下面建立了一个新的文件夹www,赋予ftpuser和www 777权限。用原系统用户montana登录ftp,可以对ftpuser目录下的内容进行读写删操作等。而用新建的michael账号登录,则只能对ftpuser下级目录www中的文件进行读写删等操作。有点奇怪!

补充:问题找到了,原来出在这里:
sudo chmod 777 /home/montana/ftpuser/www

加上一条:
sudo chmod 777 /home/montana/ftpuser

世界清静了!

看到网上个别配置教程走弯路了,ftp根目录下没有必要再建一个文件夹。

同时,似乎感觉到为什么刚才在montana登录系统下,用michael登录ftp上传文件后,文件出现小锁头标志,可能是由于非montana用户上传的原因吧。
montana
帖子: 103
注册时间: 2007-08-11 15:56
系统: Ubuntu 16.04

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#102

帖子 montana » 2016-01-26 9:26

代码: 全选

montana@L440:~$ ps aux | grep apache
root      1349  0.0  0.6 278512 24236 ?        Ss   08:40   0:00 /usr/sbin/apache2 -k start
www-data  1508  0.0  0.5 289728 21124 ?        S    08:41   0:00 /usr/sbin/apache2 -k start
www-data  1509  0.0  0.2 278584  8024 ?        S    08:41   0:00 /usr/sbin/apache2 -k start
www-data  1510  0.0  0.5 289160 19244 ?        S    08:41   0:00 /usr/sbin/apache2 -k start
www-data  1511  0.0  0.4 288588 18012 ?        S    08:41   0:00 /usr/sbin/apache2 -k start
www-data  1512  0.0  0.4 288608 18216 ?        S    08:41   0:00 /usr/sbin/apache2 -k start
www-data  2463  0.0  0.2 278656  9836 ?        S    09:17   0:00 /usr/sbin/apache2 -k start
www-data  2465  0.0  0.2 278536  8028 ?        S    09:17   0:00 /usr/sbin/apache2 -k start
www-data  2466  0.0  0.2 278536  8028 ?        S    09:17   0:00 /usr/sbin/apache2 -k start
www-data  2469  0.0  0.2 278536  8028 ?        S    09:17   0:00 /usr/sbin/apache2 -k start
www-data  2470  0.0  0.2 278536  8028 ?        S    09:17   0:00 /usr/sbin/apache2 -k start
montana   2547  0.0  0.0  16448  2468 pts/1    S+   09:23   0:00 grep --color=auto apache
这样应该算作默认www-data身份运行了吧?
montana
帖子: 103
注册时间: 2007-08-11 15:56
系统: Ubuntu 16.04

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#103

帖子 montana » 2016-01-26 16:20

因为还得用到个别windows上运行的软件,所以想在ubuntu下面装个虚拟机,安装上xp,不知道哪个虚拟机安装起来比较方便?百度了一下,似乎vmware workstation只有30天试用版,virtual box设置起来还比较麻烦,似乎只有32位的,我的64位ubuntu上无法安装。不知道有没有其他好用的虚拟机可以推荐?谢谢。
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#104

帖子 poloshiao » 2016-01-26 16:41

似乎vmware workstation只有30天试用版,virtual box设置起来还比较麻烦,似乎只有32位的,我的64位ubuntu上无法安装。
1. VMware Workstation 12 Player Free for Personal Use 沒有 30天 試用期限
1-1. 參見
https://www.vmware.com/products/player

2. virtualbox 主力是 64 bit (amd 64) 目前是 5.0.14
https://www.virtualbox.org/wiki/Downloads
2-1. 安裝方法 參考
2-1-1. https://help.ubuntu.com/community/VirtualBox
2-1-2. https://www.virtualbox.org/wiki/Linux_Downloads
montana
帖子: 103
注册时间: 2007-08-11 15:56
系统: Ubuntu 16.04

Re: 从今天起,告别windows,投入ubuntu 16.04的怀抱

#105

帖子 montana » 2016-01-26 16:41

http://download.virtualbox.org/virtualbox/5.0.14/
从这里下载了:virtualbox-5.0_5.0.14-105127~Ubuntu~wily_amd64.deb

安装的时候,提示出错:

代码: 全选

montana@L440:~/Downloads$ sudo dpkg -i virtualbox-5.0_5.0.14-105127~Ubuntu~wily_amd64.deb
[sudo] password for montana: 
Selecting previously unselected package virtualbox-5.0.
(Reading database ... 260442 files and directories currently installed.)
Preparing to unpack virtualbox-5.0_5.0.14-105127~Ubuntu~wily_amd64.deb ...
Unpacking virtualbox-5.0 (5.0.14-105127~Ubuntu~wily) ...
dpkg: dependency problems prevent configuration of virtualbox-5.0:
 virtualbox-5.0 depends on libvpx2 (>= 1.4.0); however:
  Package libvpx2 is not installed.

dpkg: error processing package virtualbox-5.0 (--install):
 dependency problems - leaving unconfigured
Processing triggers for systemd (228-4ubuntu1) ...
Processing triggers for ureadahead (0.100.0-19) ...
ureadahead will be reprofiled on next reboot
Processing triggers for hicolor-icon-theme (0.15-0ubuntu1) ...
Processing triggers for shared-mime-info (1.5-2) ...
Unknown media type in type 'all/all'
Unknown media type in type 'all/allfiles'
Processing triggers for gnome-menus (3.13.3-6ubuntu2) ...
Processing triggers for desktop-file-utils (0.22-1ubuntu3) ...
Processing triggers for bamfdaemon (0.5.2~bzr0+16.04.20151217-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for mime-support (3.59ubuntu1) ...
Errors were encountered while processing:
 virtualbox-5.0
回复