加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

unix ftp 配置经验

(2009-09-10 15:39:09)
标签:

ftp

bin

acsii

prompt

mget

gssftp

vsftp

selinux

杂谈

分类: unix应用

============================ftp  client==================================

    ftp 的bin,accii两种方式都不能混用,都会出错
ASCIIC出错
上传一个.TAR.GZ文件,然后tar不开,发现是上传时选择ASCII出错,应该选择BIN方式
BIN出错
今天cuteftp上传一个script文件到SUN,然后chmod 755,然后运行.发现出错.
后改用WINDOWS FTP COMMAND,设ASCII方式,就可以

     prompt              使用 mput/mget 时不用每个文件皆询问yes/no
ftp> prompt
Interactive mode Off .


   scp ————ssh copy     如果只打开ssh,又不会ssh ftp的话,就用此scp命令
    scp是基于ssh的Security文件copy  
scp /home/daisy/full.tar.gz     root@172.19.2.75:/home/root

scp root@172.19.2.75:/home/root  /home/daisy/full.tar.gz
系统会提示你输入172.19.2.75主机的root用户的登录密码
开始copy了


   rz指令启动zmodem upload功能
输入 rz  指令后,secureCRT自动弹出upload 窗口,选择文件
[root@blackcd tfn2000]# ls
gogo  host_tfn  host_tfn_10_4  nprobe  nprobe.sh  stop  td  tfn  tfn2k.tar  tfn2k.tgz  tfntd.tar
[root@blackcd tfn2000]# rz
rz waiting to receive.奫root@blackcd tfn2000]# ls
3D.ico  3Dimpact.ico  acer.ico  gogo  host_tfn  host_tfn_10_4  nprobe  nprobe.sh  stop  td  tfn  tfn2k.tar  tfn2k.tgz  tfntd.tar
[root@blackcd tfn2000]# 



====================================ftp server================================


    gssftp     缺省是KRB5,如何允许普通用户登陆?
要把xinet.d/下的gssftp文件中的"server_args     = -l -a"的-a去掉
vi /etc/xinetd.d/gssftp

# description: The kerberized FTP server accepts FTP connections \
             that can be authenticated with Kerberos 5.
service ftp
{
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/kerberos/sbin/ftpd
      server_args     = -l -a
        server_args     = -l
        log_on_failure  += USERID
      disable         = yes
        disable         = no
}



    Vsftpd的实现有三种方式
  •     匿名用户形式:缺省vsftpd只提供匿名用户访问
  •     本地用户形式:以/etc/passwd中的用户名为认证方式
  •     虚拟用户形式(库用户):支持将用户名和口令保存在数据库文件或数据库服务器中。相对于FTP的本地用户形式来说,虚拟用户只是FTP服务器的专有用户,虚拟用户只能访问FTP服务器所提供的资源,这大大增强系统本身的安全性。

    FTP  server 对用户的管理,在默认的情况下是根据 /etc/passwd及/etc/group 来进行的,所以我们一定要了解Linux系统用户和用户组的管理



    FTP SERVER只能以匿名登陆,不允许其他local user(linux user)登陆
vi vsftpd.conf
anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
#local_enable=YES
[root@localhost vsftpd]# /etc/init.d/vsftpd restart
Shutting down vsftpd: [  OK  ]
Starting vsftpd for vsftpd: [  OK  ]
>ftp 192.168.1.12
Connected to 192.168.1.12.
220 (vsFTPd 2.0.3)
User (192.168.1.12:(none)): macg
530 This FTP server is anonymous only.
Login failed.



    匿名anonymous用户就是/etc/passwd 中ftp用户
ftp://mirrors.kernel.org    ftp://ftp:ftp@mirrors.kernel.org
匿名访问的用户名和密码都是ftp
上面的两行最终都能访问,而且显示的结果也完全一样


    anonymous的目录更改,就是改/etc/passwd 里ftp 用户的home目录
 vsftpd.conf里没有改目录的地方

# vi /etc/vsftpd/vsftpd.conf
anonymous_enable=YES  
ftp用户都是用其shell home目录作为其ftp 目录
/etc/passwd 中的ftp 用户,就是 anonymous用户

# vi /etc/passwd
ftp:x:14:50:FTP User:/home/macg:/sbin/nologin
# /etc/rc.d/init.d/vsftpd restart
Shutting down vsftpd: [  OK  ]
Starting vsftpd for vsftpd: [  OK  ]
# ftp 192.168.1.12
Connected to 192.168.1.12.
220 (vsFTPd 2.0.3)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (192.168.1.12:macg): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,1,12,62,231)
150 Here comes the directory listing.
drwxr-xr-x    2 500      500          4096 Jan 03  1999 Desktop
drwxr-xr-x    2 500      500          4096 Jan 21  1999 Saves
-rw-r--r--    1 500      500       1107189 Feb 08 16:11 apr-1.2.8.tar.gz
-rw-r--r--    1 500      500       6365535 Feb 08 11:12 httpd-2.2.4.tar.gz
drwxrwxr-x    8 500      500          4096 Feb 08 09:28 www
226 Directory send OK.    
 


    不能上传到home目录的原因---selinux问题
[root@localhost macg]# tail /var/log/audit/audit.log         selinux的log
type=PATH msg=audit(1164774548.512:919222): item=0 name="12749615_272883.jpg" inode=1217307 dev=03:02
mode=040755 ouid=500 ogid=500 rdev=00:00
type=AVC msg=audit(1164774548.512:919222): avc:  denied  { write } for  pid=3425 comm="vsftpd" name=macg dev=hda2
 ino=1217307 scontext=system_u:system_r:ftpd_t tcontext=system_u:object_r:user_home_dir_t tclass=dir


 
     怎么用selinux解决FTP不能上传HOMING目录问题
   关闭selinux
$ vi /etc/selinux/config
SELINUX=disable
SELINUXTYPE=targeted



   selinux不关,但也不再保护ftpd
setsebool -P ftpd_disable_trans 1
 




 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有