Archive for the '服务器技术' Category

Ubuntu 10.10 server 实践–ftp proftp安装

十二 09 2010 Published by under 技术,服务器技术

今天晚上安装了ftp服务程序,我们选择proftp,首先源码下载到windows,网站http://www.proftpd.org/, 我下载的软件包为proftpd-1.3.3c.tar.gz,接下来通过昨天的方法,利用xshell把windows的源码包传到linux上,源码安装需要gcc支持,请确认系统已经安装gcc编译器,接下来具体操作步骤:

$sftp username@ip
$>put local_file remote_dir  #(> put D:proftpd-1.3.3c.tar.gz  /home/software/)
$>quit
$ssh username@ip
$cd /home/software
$tar -xzvf /home/software/proftpd-1.3.3c.tar.gz -C /home/lib
$cd /home/lib/proftpd-1.3.3c
$sudo ./configure --prefix=/usr/local/proftp
$sudo make
$sudo make install

接下来修改/usr/local/proftp/etc/proftpd.conf

# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use.  It establishes a single server
# and a single anonymous login.  It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.

ServerName                      "ProFTPD Default Installation"
ServerType                      standalone
DefaultServer                   on

# Port 21 is the standard FTP port.
Port                            21

# Don't use IPv6 support by default.
UseIPv6                         off

# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask                           022

# To prevent DoS attacks, set the maximum number of child processes
# to 30.  If you need to allow more than 30 concurrent connections
# at once, simply increase this value.  Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances                    30

# Set the user and group under which the server will run.
User                            nobody
Group                           nogroup

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot ~

# Normally, we want files to be overwriteable.
AllowOverwrite          on
SystemLog   /usr/local/proftp/log/proftpd.log

# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
  DenyAll
</Limit>

# A basic anonymous configuration, no upload directories.  If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
<Anonymous ~ftp>
  User                          ftp
  Group                         ftp

  # We want clients to be able to login with "anonymous" as well as "ftp"
  UserAlias                     anonymous ftp

  # Limit the maximum number of anonymous logins
  MaxClients                    10

  # We want 'welcome.msg' displayed at login, and '.message' displayed
  # in each newly chdired directory.
  DisplayLogin                  welcome.msg
  DisplayChdir                  .message

  # Limit WRITE everywhere in the anonymous chroot
  <Limit WRITE>
    DenyAll
  </Limit>
</Anonymous>
# user access config file path
AuthUserFile /usr/local/lib/proftp/etc/passwd
# change the auth file order
AuthOrder mod_auth_file.c mod_auth_unix.c

配置文件中我们已经配置权限验证通过文件方式。接下来我们参照http://www.proftpd.org/docs/contrib/ftpasswd.html来配置添加ftp用户。我们用到也就是

ftpasswd --passwd --name=bob--uid=1001 --file=/usr/local/lib/proftp/etc/passwd --home=/home/bob --shell=/bin/false

会提示你输入密码,输入密码后就会生成一个用户密码配置文件,路径如下: /usr/local/lib/proftp/etc/passwd,如果你不知道怎么获取uid,那么请用下面的命令查看,那个显示的数字就是了

id nobody

现在如果你启动proftp可能出现总是登录不上的情况,解决办法就是在/etc/shells 添加一行 /bin/false

最后启动你的proftp,

$sudo /usr/local/lib/proftp/sbin/proftpd

那么整个ftp就成功了,如果发生错误请查看日志文件,路径我们配置文件中也配置了 /usr/local/proftp/log/proftpd.log
如果是端口占用,请用下面命令查看是什么进程占用了

$sudo netstat -pant

查到占用21端口的进程,你可以kill,还可以更改配置文件的端口来解决这个问题。
如果你的proftp不是系统service,怎么停掉呢,方法很简单

$ps aux|grep "proftpd"
$kill id

那个/usr/local/proftp/sbin/ftpshut 命令是不能完全停止进程的,会一直占用21端口,这种停止只能让ftp用户没有办法登录。

One response so far

Ubuntu 10.10 server 实践–简单介绍

十二 08 2010 Published by under 技术,服务器技术

以前搞过Linux server,但是因为工作开发比较忙,有很长一段时间没有练习了,很多东西开始淡忘,温故而知新,所以决定重新操作一边,随便做一下笔记,以便以后使用。

下载好iso文件,在windows下使用虚拟化软件virtualbox(免费开源)安装Ubuntu Server.安装时到最后的软件选择时,因为要从头做起,不用系统做好的LAMP,Tomcat server软件包,如果用系统软件包,那就达不到练习的目的了。我只选择了OpenSSH server,因为要其他的机器传输文件到服务器上,必须有一个连接方式能够支持,那么ssh就是最好的方法。Ftp server 我们后面搭建,现在系统就只有ssh了。如果你通过网络的话也可以通过wdget来做,但是我不喜欢用server去下载东西。

接下来介绍一下SSH怎么传输文件,我的是从windows xp到Ubuntu server传输文件。windows下可以使用Xshell命令终端软件,命令使用sftp.

> sftp username@ip port
> help
bye     finish your SFTP session
cd      change your remote working directory
clear   clear screen
exit     finish your SFTP session
explore explore your local directory
get     download a file from the server to your local machine
help    give help
lcd     change and/or print local working directory
lls      list contents of a local directory
lpwd    print your local working directory
ls      list contents of a remote directory
mkdir   create a directory on the remote server
mv      move or rename a file on the remote server
put     upload a file from your local machine to the server
pwd     print your remote working directory
quit    finish your SFTP session
rename  move or rename a file on the remote server
rm      delete a file
rmdir   remove a directory on the remote server

当然你也可以选择SCP命令作为你的传输命令:scp 命令是 SSH 中非常有用的命令,在两台服务器之间直接传送文件,仅仅用 scp 一个命令就完全解决了。 你可以在一台服务器上 以 root 身份运行 #scp servername:/home/ftp/pub/file1 . 这样就把另一台服务器上的文件 /home/ftp/pub/file1 直接传到本机器的当前目录下,当然你也可以用 #scp /tmp/file2 servername:/boot 把本机上的文件 /tmp/file2 送到另一台机器的 /boot 目录下。而且整个传送过程仍然是用 SSH 加密的。在windows下需要安装一个软件Winscp就可以了。

通过sftp传输文件到服务器上,是一个非常好的windows和linux通信的方法。当然你也可以用scp,如果是linux到linux推荐scp方法传输。

天很晚了。呵呵,困死了,睡觉了,今晚收工了。^_^

No responses yet