日期:2014-05-16  浏览次数:20876 次

使用samba实现linux,windows间文件共享

经常在linux下需要用到windows下的文件,但是将文件通过ftp上传到linux上又很浪费时间,而且很浪费磁盘的空间,也很难保证两台机器上文件的同步,要是能够像windows之间那样直接进行共享就好了,下面我就们就来看看如何在linux和windows下面共享文件呢。

本文是一台windows7和两台RedHat5.3机器上进行测试,windows7IP地址为192.168.31.226,机器名为WANGHAIFENG-PC,Linux的IP分别是192.168.31.145和192.168.31.167。

(一)检查和安装samba是否安装

(1)分别检查两台机器samba的安装情况,

# uname -r
2.6.18-53.el5?????????????????????????????? //192.168.31.145
[root@dhcp_host mnt]# rpm -qa | grep samba
samba-client-3.0.25b-0.el5.4
system-config-samba-1.2.39-1.el5
samba-3.0.25b-0.el5.4
samba-common-3.0.25b-0.el5.4

# uname -r
2.6.18-53.el5????????????????????????????? //192.168.31.167
#rpm -qa | grep samba
samba-common-3.0.25b-0.el5.4
samba-client-3.0.25b-0.el5.4

从上面可以看出,145安装了samba的服务端和客户端,而在167上只安装了samba的客户端,因此在145能够查看和共享文件,而在167上只能查看文件,假如需要共享文件,可以在RedHat的安装光盘中获得samba-3.0.25b-0.el5.4.rpm进行安装,system-config-samba-1.2.39-1.el5是samba图形化的配置程序。

(2)安装samba Server端,在192.168.31.167上进行安装

#rpm -Uvh samba-3.0.33-3.7.el5.i386.rpm
warning: samba-3.0.33-3.7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
??????? perl(Convert::ASN1) is needed by samba-3.0.33-3.7.el5.i386
??????? samba-common = 0:3.0.33-3.7.el5 is needed by samba-3.0.33-3.7.el5.i386

这是由于原先的Samba版本比现有的版本低,因此需要进行升级,否则无法安装。

# rpm -Uvh samba-common-3.0.33-3.7.el5.i386.rpm
warning: samba-common-3.0.33-3.7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
??????? samba-common = 0:3.0.25b-0.el5.4 is needed by (installed) samba-client-3.0.25b-0.el5.4.i386

由于samba-client依赖于现在的samba-common,因此先删除samba-client,然后再升级安装samba-common

# rpm -e samba-client-3.0.25b-0.el5.4.i386
# rpm -Uvh samba-common-3.0.33-3.7.el5.i386.rpm

warning: samba-common-3.0.33-3.7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...??????????????? ########################################### [100%]
?? 1:samba-common?????????? ########################################### [100%]

继续安装samba-3.0.33-3.7.el5.i386.rpm

#rpm -Uvh samba-3.0.33-3.7.el5.i386.rpm
warning: samba-3.0.33-3.7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
??????? perl(Convert::ASN1) is needed by samba-3.0.33-3.7.el5.i386

从上图可以看出来还缺少perl(Convert::ASN1) 这个模块,在安装光盘中找到perl-Convert-ASN1-0.20-1.1.noarch.rpm这个文件

# rpm -Uvh perl-Convert-ASN1-0.20-1.1.noarch.rpm
warning: perl-Convert-ASN1-0.20-1.1.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...??????????????? ########################################### [100%]
?? 1:perl-Convert-ASN1????? ########################################### [100%]
#rpm -Uvh samba-3.0.33-3.7.el5.i386.rpm
warning: samba-3.0.33-3.7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...??????????????? ########################################### [100%]
?? 1:samba????????????????? ########################################### [100%]
# rpm -Uvh samba-client-3.0.33-3.7.el5.i386.rpm
warning: samba-client-3.0.33-3.7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...??????????????? ########################################### [100%]
?? 1:samba-client?????????? ########################################### [100%]
# rpm -qa | grep samba
samba-common-3.0.33-3.7.el5
samba-3.0.33-3.7.el5
samba-client-3.0.33-3.7.el5

samba就已经安装完成了,上面这些安装文件都能够在RedHat的安装CD中找到。

(3)添加samba用户

使用smbpasswd添加samba用户,用户必须是linux系统中已有的用户