用自己的账号登录进去,rw权限可以实现!属于自己的私有空间!可以进行任意操作!
用lzw账号登录:
把smb.conf 文件中public中的打印机那行去掉!
[root@gjp99 pub]# service smb restart
在用lzw账号登录:(查看public有什么不同)
4.用linux系统作为samba客户端进行访问:
[root@mail ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:F9:1C:6F
inet addr:192.168.10.2 Bcast:192.168.10.255 Mask:255.255.255.0
[root@mail ~]# ping 192.168.10.99
PING 192.168.10.99 (192.168.10.99) 56(84) bytes of data.
64 bytes from 192.168.10.99: icmp_seq=1 ttl=64 time=2.34 ms
64 bytes from 192.168.10.99: icmp_seq=2 ttl=64 time=0.394 ms
查看是否安装了smb客户端:
[root@mail ~]# rpm -qa |grep samba
samba-common-3.0.33-3.14.el5
samba-client-3.0.33-3.14.el5
用账号gjp登录测试:
[root@mail ~]# smbclient -L \\192.168.10.99 -U gjp
Password:
Domain=[GJP99] OS=[Unix] Server=[Samba 3.0.33-3.14.el5]
Sharename Type Comment
--------- ---- -------
public Disk public dir
smbgjp Disk gjp share dir
smblzw Disk lzw share dir
IPC$ IPC IPC Service (Samba Server Version 3.0.33-3.14.el5)
gjp Disk Home Directories
Domain=[GJP99] OS=[Unix] Server=[Samba 3.0.33-3.14.el5]
Server Comment
--------- -------
Workgroup Master
--------- -------
MYGROUP GJP99
WORKGROUP PC-201203120919
[root@mail ~]# smbclient //192.168.10.99/smbgjp -U gjp
Password:
Domain=[GJP99] OS=[Unix] Server=[Samba 3.0.33-3.14.el5]
smb: \> dir
. D 0 Fri Aug 3 17:58:40 2012
.. D 0 Fri Aug 3 17:22:35 2012
f1.gjp 0 Fri Aug 3 17:31:46 2012
38752 blocks of size 262144. 27325 blocks available
smb: \> ? //下面都是ftp指令
? altname archive blocksize cancel
case_sensitive cd chmod chown close
del dir du exit get
getfacl hardlink help history lcd
link lock lowercase ls mask
md mget mkdir more mput
newer open posix posix_open posix_mkdir
posix_rmdir posix_unlink print prompt put
pwd q queue quit rd
recurse reget rename reput rm
rmdir showacls setmode stat symlink
tar tarmode translate unlock volume
vuid wdel logon listconnect showconnect
!
smb: \> dir 显示远程
. D 0 Fri Aug 3 17:58:40 2012
.. D 0 Fri Aug 3 17:22:35 2012
f1.gjp 0 Fri Aug 3 17:31:46 2012
38752 blocks of size 262144. 27325 blocks available
smb: \> !dir 显示本地
Desktop extmail-1.2.tar.gz
Maildir extman-1.1.tar.gz
Unix-Syslog-1.1 install.log
Unix-Syslog-1.1.tar.gz install.log.syslog
anaconda-ks.cfg mbox
courier-authlib-0.63.1.20111230.tar.bz2 postfix-2.8.2.tar.gz
smb: \> put mbox 上传文件
putting file mbox as \mbox (28.5 kb/s) (average 28.5 kb/s)
smb: \> dir
. D 0 Fri Aug 3 18:44:04 2012
.. D 0 Fri Aug 3 17:22:35 2012
f1.gjp 0 Fri Aug 3 17:31:46 2012
mbox A 1399 Fri Aug 3 18:44:04 2012
38752 blocks of size 262144. 27325 blocks available
smb: \> mget f1* 批量下载文件
Get file f1.gjp? y
getting file \f1.gjp of size 0 as f1.gjp (0.0 kb/s) (average 0.0 kb/s)
smb: \> !dir
Desktop extman-1.1.tar.gz
Maildir f1.gjp
Unix-Syslog-1.1 install.log
Unix-Syslog-1.1.tar.gz install.log.syslog
anaconda-ks.cfg mbox
courier-authlib-0.63.1.20111230.tar.bz2 postfix-2.8.2.tar.gz
extmail-1.2.tar.gz
smb: \> quit 退出
[root@mail ~]# mount -t cifs //192.168.10.99/smbgjp /mnt/smb -o username=gjp%123
[root@mail ~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
//192.168.10.99/smbgjp on /mnt/smb type cifs (rw,mand)挂载成功
[root@mail ~]# umount /mnt/smb
[root@mail ~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
[root@mail ~]# vim /etc/fstab
增加此行:
//192.168.10.99/smbgjp /mnt/smb cifs defaults,username=gjp%123 0 0
[root@mail ~]# mount -a
[root@mail ~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
//192.168.10.99/smbgjp on /mnt/smb type cifs (rw,mand)
可以实现,但是这样不安全,如果有人查看/etc/fstab,则能够看到用户名和密码!
把密码放到一个文件中:
//192.168.10.99/smbgjp /mnt/smb cifs defaults,credentials=/etc/samba/f1 0 0
[root@mail samba]# vim f1
username=gjp
passwd=123
[root@mail samba]# mount -a
[root@mail samba]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
//192.168.10.99/smbgjp on /mnt/smb type cifs (rw,mand)