ubuntu16.04搭建ssh,samba,svn服务器记录

前端之家收集整理的这篇文章主要介绍了ubuntu16.04搭建ssh,samba,svn服务器记录前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_404_1@1.搭建ssh服务器

sudo apt-get install openssh-server
安装完成即可使用

2.搭建samba

安装samba:

sudo apt-get install samba

配置:

修改/etc/smb.conf
在smb.conf的最后添加新用户即可:
[hello]
comment = samba
path = /home/hello/work/share
browseable = yes
guest ok = no
writeable = yes

其中,[jinwei]是用户名
path是samba服务器共享目录。
browseable = yes和writeable = yes表明可写可浏览。

添加用户,设置密码:

sudo smbpasswd -a hello
设置完成后启动samba服务器即可。

测试

在windows中的文件浏览器中输入\server\即可看到hello用户,点击输入用户名和密码即可完成访问:

samba服务器的操作

启动samba服务器:
/etc/init.d/samba start
重启:
/etc/init.d/samba restart
查询状态
/etc/init.d/samba status
停止:
/etc/init.d/samba stop

配置为开机自启动

第一步:
在/etc/init.d新建samba.sh脚本
内容如下:

  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: samba.sh
  4. # required-start: $local_fs $remote_fs $network $syslog
  5. # required-Stop: $local_fs $remote_fs $network $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: starts the svnd.sh daemon
  9. # Description: starts svnd.sh using start-stop-daemon
  10. ### END INIT INFO
  11. /etc/init.d/samba start

第二步:
执行update-rc.d samba.sh defaults

取消svn开机自启动
执行:update-rc.d -f samba.sh remove

3.搭建svn服务器

安装subversion

sudo apt-get install subversion

创建svn仓库

svnadmin create /xxx/xxxx

第二步:配置

配置三个文件
1.svnserve.conf
打开所示四项注释,并将anon-access = read改为anon-access = none 。

  1. [general]
  2. ### The anon-access and auth-access options control access to the
  3. ### repository for unauthenticated (a.k.a. anonymous) users and
  4. ### authenticated users,respectively.
  5. ### Valid values are "write","read",and "none".
  6. ### Setting the value to "none" prohibits both reading and writing;
  7. ### "read" allows read-only access,and "write" allows complete
  8. ### read/write access to the repository.
  9. ### The sample settings below are the defaults and specify that anonymous
  10. ### users have read-only access to the repository,while authenticated
  11. ### users have read and write access to the repository.
  12. anon-access = none
  13. auth-access = write
  14. ### The password-db option controls the location of the password
  15. ### database file. Unless you specify a path starting with a /,### the file's location is relative to the directory containing
  16. ### this configuration file.
  17. ### If SASL is enabled (see below),this file will NOT be used.
  18. ### Uncomment the line below to use the default password file.
  19. password-db = passwd
  20. ### The authz-db option controls the location of the authorization
  21. ### rules for path-based access control. Unless you specify a path
  22. ### starting with a /,the file's location is relative to the
  23. ### directory containing this file. The specified path may be a
  24. ### repository relative URL (^/) or an absolute file:// URL to a text
  25. ### file in a Subversion repository. If you don't specify an authz-db,### no path-based access control is done.
  26. ### Uncomment the line below to use the default authorization file.
  27. authz-db = authz

2.passwd
在user后增加“姓名 = 密码”即可

  1. ### This file is an example password file for svnserve.
  2. ### Its format is similar to that of svnserve.conf. As shown in the
  3. ### example below it contains one section labelled [users].
  4. ### The name and password for each user follow,one account per line.
  5.  
  6. [users]
  7. # harry = harryssecret
  8. # sally = sallyssecret
  9. aaa = 11223344
  10. bbb = 123456

3.authz
在[groups]下添加分组信息,然后在[/]目录下添加用户和组的访问权限即可:
如:

  1. [groups]
  2. # harry_and_sally = harry,sally
  3. # harry_sally_and_joe = harry,sally,&joe
  4. admin = aaa,bbb
  5. [/]
  6. @admin = rw

组前面必须加@符号。

启动svn 服务器:

svnserve -d -r /xxx

测试

ubuntu下执行:
svn co svn://svnserver/repo
比如:
svn co svn://192.168.1.100/

完整举例:

首先创建目录:
cd /
mkdir svn
cd svn
mkdir repo1
mkdir reop2

其次,创建仓库
svnadmin create /svn/repo1
svnadmin create /svn/repo2

然后分别按照前面所述,配置repo1和repo2的conf/passwd.conf/authz,conf/svnservse.conf三个文件

然后启动svn服务器:
执行
svnserve -d -r /svn
注意是/svn,而不是/svn/repo1。。。

最后测试:
执行svn co svn://192.168.1.100/repo1

windows下可安装tortoiseSVN来访问svn服务器。

制作开机自启动脚本

第一步:
在/etc/init.d下新建svnd.sh脚本,内容如下:

  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: svnd.sh
  4. # required-start: $local_fs $remote_fs $network $syslog
  5. # required-Stop: $local_fs $remote_fs $network $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: starts the svnd.sh daemon
  9. # Description: starts svnd.sh using start-stop-daemon
  10. ### END INIT INFO
  11. svnserve -d -r /svn

第二步: 执行update-rc.d svnd.sh defaults 重启即可 取消svn开机自启动 执行:update-rc.d -f svnd.sh remove

猜你在找的Ubuntu相关文章