打开/etc/selinux/config
将selinux=enforcing或permissive改成disabled。
记得要重新启动服务器!
当然还要确定以下问题:
1,用户是否被vsftpd限制登录,比如用户名在/etc/ftpusers中,并被阻止登录了
2,vsftpd.conf中是否打开了pam认证的选项(自己编译安装的时候常因为这个出错)(看vsftpd.conf中是否有pam_service_name=ftp或vsftpd.到底是哪个要看
PAM模块的服务文件/etc/pam.d下是谁.我的是ftp且它的配置如下:
#%PAM-1.0
authrequired/lib/security/pam_listfile.soitem=usersense=denyfile=/etc/ftpusersonerr=succeed
authrequired/lib/security/pam_unix.soshadownullok
authrequired/lib/security/pam_shells.so
accountrequired/lib/security/pam_unix.so
sessionrequired/lib/security/pam_unix.so
如果/etc/ftpusers有的用户将被deny
3,相关文件夹的权限是否正确.
关于“vsftpd部分本地用户不能登录,部分可以”的问题,
系统中原来就有的本地帐号都不能登录,我的/etc/vsftpd/vsftpd.conf文件的配置如下:
local_enable=YES
write_enable=YES
chroot_local_user=YES
pam_service_name=vsftpd
/etc/pam.d/vsftpd存在且正常。
登录时错误信息都是一样的:
500OOPS:cannotchangedirectory:/home/xxxx
Loginfailed.
421Servicenotavailable,remoteserverhasclosedconnection
他们的home目录都是/home/xxxx。/home和/home/xxxx的权限都是755。
以上这些帐号都不能ftp登录,这些都是平常经常使用的,可以用shell登录的。
我新创建了一个usr1帐号
#useradd-Gtest-d/tmp/usr1usr1
能ftp登录,他的home为/tmp/usr1,在/分区上。而/home我是mount到/dev/hda9上的。
#mount
/dev/hdb1on/typeext3(rw)
/dev/hda9on/hometypeext2(rw)
所以,我猜想:是否是由于/home分区的原因,而造成“主目录在/home分区的帐号”都不能登录呢?
为了验证以上设想,我试着再创建了一个帐号
useradd-Gtest-d/home/usr3usr3
/home,/home/usr3的权限都是755。
usr3ftp登录失败。
500OOPS:cannotchangedirectory:/home/usr3
Loginfailed.
421Servicenotavailable,remoteserverhasclosedconnection
至此,我觉得可以确定是由于/home分区的原因,而造成“主目录在/home分区的帐号”都不能登录。
参考文章:
IfinishedmysecondupgradetoFedoraCore4.Noteverythingisironedoutyetwiththebuildofcourse.ButonethingisforsurealothashappenedtotheRedHatIknewbefore.
Imustsayofallthechanges,formethenicestadditionisthenewSELinuxextensions.FordeepbackgroundonthereasonsforandtheoryofSELinuxread,TheInevitabilityofFailure:TheFlawedAssumptionofSecurityinModernComputingEnvironments
ThemoreIworkwithSELinuxthemoreIrealizeIneedtoknowaboutit,andhowexactlyitdoesallitsstuff.Itcertainlychangesthingsrelatingtousers,directoriesandaccess.AsIamstartingtolearnit,I'msureI'mdoingthingsthehard-way.:)
Themajordifference,sofarforme,inRedHat'sSELinuxisthewayftpishandled.vsftpdisstilltheserverwhichisgreat.However,itseemstobedesignedtorunasadaemonratherthaninvokedviaxinet.d.Ifyougrabaworkingcopyofthexinet.dfileforvsftpdyoucaninvokeitviaxinet.dwrapper.Ididmyfirstserverupgradeinthismanner.ThecurrentoneIamtryingasadaemon.IcertainlythinkIwillmisssomeofthefeaturesthatthexinet.dwrapperbrings,andmayyetreturntoit.
OfalltheissuesIsawmostnotableisifyouwanttoenablechrootdirectory'soutsideofthenormal/home/xxxvsftpd.Thesewillfailwitha
500OOPS:cannotchangedirectory:/mnt/xxxxx
IwasabletouseftpifIloggedinwithanaccountwithadirectoryin/home,butonceIsetauseraccounttohaveahomedriveoutsideof/home(inthiscaseonamountedsecondarydisk)vsftpdbarfstheabove.
IfoundinformationattheNSAthatindicatesyoucandisableSELinuxprotectionoftheftpdaemon.
setsebool-Pftpd_disable_trans1
Thisseemsabitdrastic.Itcertainlyworksfornowthough.
Ithinkultimatelytheissueresideswithpolicies,butasSELinuxpoliciesarenewtome,itwilltaketimebeforeitallgetssortedout.AsIspendtimewiththenewSELinuxextensionsinFedoraCore4Iwillkeepyouupdatedonmythoughtsandconfigurationlessons.
解决办法:
#setseboolftpd_disable_trans1
#servicevsftpdrestart
我用的是FC4,按照你上一帖子里的方法试了,马上就解决了。所以,可以确定原因就在SELinux。