Chinaunix首页 | 论坛 | 博客
  • 博客访问: 33670
  • 博文数量: 7
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 10
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-30 07:26
文章分类

全部博文(7)

文章存档

2014年(7)

分类: 系统运维

2014-03-10 13:02:20

      自己学习linux的时候最初接受的就是命令行,自己一开始就爱上了它,所以我学习linux从不在桌面环境下面,我开始安装的linux只有221个包,因为我的机子太老了,所以安装的时候连图形界面都没出来,自己安装后就开始一步步完善系统,需要什么就去装什么。最初的是网络配置
Linux 网络配置:
手动添加ip:
1.激活网卡:ifconfig eth0 up
2.修改、etc/sysconfig/network-scripts/ifcfg-eth0文件
DEVICE=eth0;#物理设备名称
IPADDR=……….#ip地址
NETMASK=…….#掩码值
NETWORK=……#网络地址(可不要)
BROADCAST=…..#广播地址(可不要)
GATEWAY=…….#网关地址
ONBOOT=”yes”#引导时是否激活设备
USERCTL=”no”#非root用户是否可以使用该设备
BOOTPROTO=static#静态地址
DNS1=
DNS2=
3.重启网络设备
Root权限下:service network restart
4启动或关闭防火墙
Root权限下:service iptables  on
关闭:service iptables off

第二步:我们就要实现ssh配置了,最小化安装ssh也是有的,只需要你去简单配置一下

vim /etc/ssh/sshd_config//用vim编辑器打开sshd配置文件
Protcol 2# 修改后变为此状态,仅使用SSH2
ServerKeyBits 1024 # 修改后变为此状态,将ServerKey强度改为1024比特
PermitRootLogin yes  # 允许用root进行登录
PasswordAuthentication yes # 修改后变为此状态,允许密码方式的登录
PermitEmptyPasswords no  # 修改后变为此状态,禁止空密码进行登录
Port 22
“Port”设置sshd监听的端口号。
ListenAddress 192.168.1.1
“ListenAddress”设置sshd服务器绑定的IP地址。

第三步:就是利用ssh登陆软件远程登陆服务器进行维护安装软件了,我最喜欢用的软件就是putty软件,在网上可以很容易下到,软件很容易掌握。

第四步:下面我们远程登陆后,执行的第一个命令就是yum update  更新一下你的yum数据仓库,这样你的系统就会健全一点。

第五步:我们要实现linux和windows之间的文件共享,这样我们才可以很好的配置服务器

我要配置的samba是要实现既要有不需要有密码就可以访问的,也有需要用户和密码才可以访问的,权限全部为777(如果你不知道777是什么我建议你再去看看我前面的博客),下面开始


点击(此处)折叠或打开

  1. yum install samba
  2. //假定你要建立的用户名是sun
  3. mkdir /home/sun //(需要用户名和密码才可以访问)
  4. mkdir /home/public //公共文件
  5. rm -rf /etc/samba/smb.conf //删除原来的配置文件 把我的配置文件拷过去
  6. cp smb.conf /etc/samba/smb.conf //cp我的配置文件
  7. getsebool -a |grep samba //查看关于samba的布尔值
  8. setsebool -P samba_export_all_rw on //配置布尔值
  9. setsebool -P samba_create_home_dirs on
  10. setsebool -P samba_enable_home_dirs on

  11. chcon -t samba_share_t /home/sunpengqi //改变文件的类型
  12. chcon -t samba_share_t /home/public
  13. //权限设置
  14. chmod -R 777 /home/sunpengqi
  15. chmod -R 777 /home/public
  16. //
  17. 开放445端口
  18. netstat -ntupl //查看所有服务端口
  19. vim /etc/sysconfig/iptables //编辑开放445端口
  20.  
  21. service smb restart
  22. service iptables restart
  23. /usr/sbin/useradd -p 123456 sun
  24. smbpasswd sun
  25. //输入密码

  26. service smb restart
我的smb配置文件

点击(此处)折叠或打开

  1. # This is the main Samba configuration file. You should read the
  2. # smb.conf(5) manual page in order to understand the options listed
  3. # here. Samba has a huge number of configurable options (perhaps too
  4. # many!) most of which are not shown in this example
  5. #
  6. # For a step to step guide on installing, configuring and using samba,
  7. # read the Samba-HOWTO-Collection. This may be obtained from:
  8. # http://
  9. #
  10. # Many working examples of smb.conf files can be found in the
  11. # Samba-Guide which is generated daily and can be downloaded from:
  12. # http://
  13. #
  14. # Any line which starts with a ; (semi-colon) or a # (hash)
  15. # is a comment and is ignored. In this example we will use a #
  16. # for commentry and a ; for parts of the config file that you
  17. # may wish to enable
  18. #
  19. # NOTE: Whenever you modify this file you should run the command "testparm"
  20. # to check that you have not made any basic syntactic errors.
  21. #
  22. #---------------
  23. # SELINUX NOTES:
  24. #
  25. # If you want to use the useradd/groupadd family of binaries please run:
  26. # setsebool -P samba_domain_controller on
  27. #
  28. # If you want to share home directories via samba please run:
  29. # setsebool -P samba_enable_home_dirs on
  30. #
  31. # If you create a new directory you want to share you should mark it as
  32. # "samba_share_t" so that selinux will let you write into it.
  33. # Make sure not to do that on system directories as they may already have
  34. # been marked with othe SELinux labels.
  35. #
  36. # Use ls -ldZ /path to see which context a directory has
  37. #
  38. # Set labels only on directories you created!
  39. # To set a label use the following: chcon -t samba_share_t /path
  40. #
  41. # If you need to share a system created directory you can use one of the
  42. # following (read-only/read-write):
  43. # setsebool -P samba_export_all_ro on
  44. # or
  45. # setsebool -P samba_export_all_rw on
  46. #
  47. # If you want to run scripts (preexec/root prexec/print command/...) please
  48. # put them into the /var/lib/samba/scripts directory so that smbd will be
  49. # allowed to run them.
  50. # Make sure you COPY them and not MOVE them so that the right SELinux context
  51. # is applied, to check all is ok use restorecon -R -v /var/lib/samba/scripts
  52. #
  53. #--------------
  54. #
  55. #======================= Global Settings =====================================
  56.     
  57. [global]
  58.     
  59. # ----------------------- Network Related Options -------------------------
  60. #
  61. # workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
  62. #
  63. # server string is the equivalent of the NT Description field
  64. #
  65. # netbios name can be used to specify a server name not tied to the hostname
  66. #
  67. # Interfaces lets you configure Samba to use multiple interfaces
  68. # If you have multiple network interfaces then you can list the ones
  69. # you want to listen on (never omit localhost)
  70. #
  71. # Hosts Allow/Hosts Deny lets you restrict who can connect, and you can
  72. # specifiy it as a per share option as well
  73. #
  74.     workgroup = workgroup
  75.     server string = Samba Server Version %v
  76.     
  77. ;    netbios name = MYSERVER
  78.     
  79. ;    interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
  80. ;    hosts allow = 127. 192.168.12. 192.168.13.
  81.     
  82. # --------------------------- Logging Options -----------------------------
  83. #
  84. # Log File let you specify where to put logs and how to split them up.
  85. #
  86. # Max Log Size let you specify the max size log files should reach
  87.     
  88.     # logs split per machine
  89.     log file = /var/log/samba/log.%m
  90.     # max 50KB per log file, then rotate
  91.     max log size = 50
  92. map to guest = bad user
  93.     
  94. # ----------------------- Standalone Server Options ------------------------
  95. #
  96. # Scurity can be set to user, share(deprecated) or server(deprecated)
  97. #
  98. # Backend to store user information in. New installations should
  99. # use either tdbsam or ldapsam. smbpasswd is available for backwards
  100. # compatibility. tdbsam requires no further configuration.

  101.     security = user
  102.     passdb backend = tdbsam


  103. # ----------------------- Domain Members Options ------------------------
  104. #
  105. # Security must be set to domain or ads
  106. #
  107. # Use the realm option only with security = ads
  108. # Specifies the Active Directory realm the host is part of
  109. #
  110. # Backend to store user information in. New installations should
  111. # use either tdbsam or ldapsam. smbpasswd is available for backwards
  112. # compatibility. tdbsam requires no further configuration.
  113. #
  114. # Use password server option only with security = server or if you can't
  115. # use the DNS to locate Domain Controllers
  116. # The argument list may include:
  117. # password server = My_PDC_Name [My_BDC_Name] [My_Next_BDC_Name]
  118. # or to auto-locate the domain controller/s
  119. # password server = *
  120.     
  121.     
  122. ;    security = domain
  123. ;    passdb backend = tdbsam
  124. ;    realm = MY_REALM

  125. ;    password server = <NT-Server-Name>

  126. # ----------------------- Domain Controller Options ------------------------
  127. #
  128. # Security must be set to user for domain controllers
  129. #
  130. # Backend to store user information in. New installations should
  131. # use either tdbsam or ldapsam. smbpasswd is available for backwards
  132. # compatibility. tdbsam requires no further configuration.
  133. #
  134. # Domain Master specifies Samba to be the Domain Master Browser. This
  135. # allows Samba to collate browse lists between subnets. Don't use this
  136. # if you already have a Windows NT domain controller doing this job
  137. #
  138. # Domain Logons let Samba be a domain logon server for Windows workstations.
  139. #
  140. # Logon Scrpit let yuou specify a script to be run at login time on the client
  141. # You need to provide it in a share called NETLOGON
  142. #
  143. # Logon Path let you specify where user profiles are stored (UNC path)
  144. #
  145. # Various scripts can be used on a domain controller or stand-alone
  146. # machine to add or delete corresponding unix accounts
  147. #
  148. ;    security = user
  149. ;    passdb backend = tdbsam
  150.     
  151. ;    domain master = yes
  152. ;    domain logons = yes
  153.     
  154.     # the login script name depends on the machine name
  155. ;    logon script = %m.bat
  156.     # the login script name depends on the unix user used
  157. ;    logon script = %u.bat
  158. ;    logon path = \\%L\Profiles\%u
  159.     # disables profiles support by specifing an empty path
  160. ;    logon path =
  161.     
  162. ;    add user script = /usr/sbin/useradd "%u" -n -g users
  163. ;    add group script = /usr/sbin/groupadd "%g"
  164. ;    add machine script = /usr/sbin/useradd -n -c "Workstation (%u)" -M -d /nohome -s /bin/false "%u"
  165. ;    delete user script = /usr/sbin/userdel "%u"
  166. ;    delete user from group script = /usr/sbin/userdel "%u" "%g"
  167. ;    delete group script = /usr/sbin/groupdel "%g"
  168.     
  169.     
  170. # ----------------------- Browser Control Options ----------------------------
  171. #
  172. # set local master to no if you don't want Samba to become a master
  173. # browser on your network. Otherwise the normal election rules apply
  174. #
  175. # OS Level determines the precedence of this server in master browser
  176. # elections. The default value should be reasonable
  177. #
  178. # Preferred Master causes Samba to force a local browser election on startup
  179. # and gives it a slightly higher chance of winning the election
  180. ;    local master = no
  181. ;    os level = 33
  182. ;    preferred master = yes
  183.     
  184. #----------------------------- Name Resolution -------------------------------
  185. # Windows Internet Name Serving Support Section:
  186. # Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
  187. #
  188. # - WINS Support: Tells the NMBD component of Samba to enable it's WINS Server
  189. #
  190. # - WINS Server: Tells the NMBD components of Samba to be a WINS Client
  191. #
  192. # - WINS Proxy: Tells Samba to answer name resolution queries on
  193. # behalf of a non WINS capable client, for this to work there must be
  194. # at least one    WINS Server on the network. The default is NO.
  195. #
  196. # DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
  197. # via DNS nslookups.
  198.     
  199. ;    wins support = yes
  200. ;    wins server = w.x.y.z
  201. ;    wins proxy = yes
  202.     
  203. ;    dns proxy = yes
  204.     
  205. # --------------------------- Printing Options -----------------------------
  206. #
  207. # Load Printers let you load automatically the list of printers rather
  208. # than setting them up individually
  209. #
  210. # Cups Options let you pass the cups libs custom options, setting it to raw
  211. # for example will let you use drivers on your Windows clients
  212. #
  213. # Printcap Name let you specify an alternative printcap file
  214. #
  215. # You can choose a non default printing system using the Printing option
  216.     
  217.     load printers = yes
  218.     cups options = raw

  219. ;    printcap name = /etc/printcap
  220.     #obtain list of printers automatically on SystemV
  221. ;    printcap name = lpstat
  222. ;    printing = cups

  223. # --------------------------- Filesystem Options ---------------------------
  224. #
  225. # The following options can be uncommented if the filesystem supports
  226. # Extended Attributes and they are enabled (usually by the mount option
  227. # user_xattr). Thess options will let the admin store the DOS attributes
  228. # in an EA and make samba not mess with the permission bits.
  229. #
  230. # Note: these options can also be set just per share, setting them in global
  231. # makes them the default for all shares

  232. ;    map archive = no
  233. ;    map hidden = no
  234. ;    map read only = no
  235. ;    map system = no
  236. ;    store dos attributes = yes


  237. #============================ Share Definitions ==============================
  238.     
  239. [homes]
  240.     comment = Home Directories
  241.     browseable = no
  242.     writable = yes
  243. ;    valid users = %S
  244. ;    valid users = MYDOMAIN\%S
  245.     
  246. [printers]
  247.     comment = All Printers
  248.     path = /var/spool/samba
  249.     browseable = no
  250.     guest ok = no
  251.     writable = no
  252.     printable = yes
  253.     
  254. # Un-comment the following and create the netlogon directory for Domain Logons
  255. ;    [netlogon]
  256. ;    comment = Network Logon Service
  257. ;    path = /var/lib/samba/netlogon
  258. ;    guest ok = yes
  259. ;    writable = no
  260. ;    share modes = no
  261.     
  262.     
  263. # Un-comment the following to provide a specific roving profile share
  264. # the default is to use the user's home directory
  265. ;    [Profiles]
  266. ;    path = /var/lib/samba/profiles
  267. ;    browseable = no
  268. ;    guest ok = yes
  269.     
  270.     
  271. # A publicly accessible directory, but read only, except for people in
  272. # the "staff" group
  273. ;    [public]
  274. ;    comment = Public Stuff
  275. ;    path = /home/samba
  276. ;    public = yes
  277. ;    writable = yes
  278. ;    printable = no
  279. ;    write list = +staff
  280. [sun]
  281. comment = sunpengqi
  282. path = /home/sun
  283. browseable = yes
  284. readonly = no
  285. writable = yes
  286. valid users =sun
  287. ;guest ok = yes
  288. ;guest ok = no

  289. [public]
  290. comment = sunpengqi
  291. path = /home/public
  292. public = yes
  293. writable = yes
  294. guest ok = yes
  295. ;valid users = "root" ,@"everyone","admin" ,"guest"
下面我们的samba就配置好了,就这样你的简单服务器就配置了一个雏形了,有了可以远程登录,有了yum,有了samab实现文件传输,你可以干你想干的一切了。
以上都是我亲身试验的,如果你看了有什么问题请给我发邮件,我会尽快给你解答的。



阅读(2107) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~