svn+ssh服务器与客户端配置方法

svn+ssh简介

根据官网Tunneling over SSH介绍,svn支持通过ssh隧道访问。本文参考官网进行演示。

服务端配置

服务器

svn服务器为一台阿里云服务器,主机名为centos8,域名为thesre.cn。

软件安装

使用包管理器spack安装subversion,本次演示不指定版本,安装一个preferred的版本。

[thesre@centos8 ~]$ spack install subversion
==> Installing apr-1.7.0-zuo6zrpcmg7btzbx6xul5i542oqfioqa
==> No binary for apr-1.7.0-zuo6zrpcmg7btzbx6xul5i542oqfioqa found: installing from source
==> Fetching https://spack-llnl-mirror.s3-us-west-2.amazonaws.com/_source-cache/archive/48/48e9dbf45ae3fdc7b491259ffb6ccf7d63049ffacbc1c0977cced095e4c2d5a2.tar.gz
######################################################################## 100.0%
==> apr: Executing phase: 'autoreconf'
==> apr: Executing phase: 'configure'
==> apr: Executing phase: 'build'
==> apr: Executing phase: 'install'
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/apr-1.7.0-zuo6zrpcmg7btzbx6xul5i542oqfioqa
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/libbsd-0.10.0-4yfr36rbg5jlp2q4yolagnyf5ognbxhx
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/libiconv-1.16-5d5uvwewuwzki4z4xxgeejefocxoyip7
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/berkeley-db-18.1.40-w4xsitrtckvtvtjebti23vu4fwxmezm3
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/pkgconf-1.7.3-oswo2hulw6iit2lsnuibgrhkd7w46zpz
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/zlib-1.2.11-vm7mszxxyvic3ej7jmrxrwhu4c7spvys
==> Installing lz4-1.9.2-cpihutxpgbes6mhunlpcmycb5ykykxc2
==> No binary for lz4-1.9.2-cpihutxpgbes6mhunlpcmycb5ykykxc2 found: installing from source
==> Fetching https://spack-llnl-mirror.s3-us-west-2.amazonaws.com/_source-cache/archive/65/658ba6191fa44c92280d4aa2c271b0f4fbc0e34d249578dd05e50e76d0e5efcc.tar.gz
######################################################################## 100.0%
==> lz4: Executing phase: 'edit'
==> lz4: Executing phase: 'build'
==> lz4: Executing phase: 'install'
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/lz4-1.9.2-cpihutxpgbes6mhunlpcmycb5ykykxc2
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/xz-5.2.5-lu2laqfkvnenj3h7a6dgown7iw3zi4bo
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/libffi-3.3-ie7eaqv5iypzofel4gkao6x3k7d36sc5
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/libuuid-1.0.3-2syrordr2ty43ucobr4qjf6hoasrdnpk
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/expat-2.2.10-y2mtmfq5e7voeg5p5rjn6td7uzwzenvh
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/tar-1.32-i7mwnim22bv2hg7xytnn3b3aywf3zm3j
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/diffutils-3.7-3r5s47ufek24nuavkcyorrsvhgnevvid
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/ncurses-6.2-ddvl2niakwrcs5erwfmseopy6w7twdcz
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/libxml2-2.9.10-pxsxz3hpqcppwis6h5cxzlple72kpswu
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/bzip2-1.0.8-f5gxiqbglgzyyz47dgxgyphyj3frdkd6
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/readline-8.0-v3l6hs5w6mdkxqqs3nhdizs7y4ilyt3h
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/gettext-0.21-4behvt2cvgpjco4xx34yowliooktd3kg
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/gdbm-1.18.1-q6facxrdaiv2cngjr5igc7fu64f7lsdl
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/sqlite-3.33.0-3fjee5zne5hqqaia2jddyxqea54bka57
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/perl-5.32.0-dew37butfq22i4rnooqtxxveq3mwq5rq
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/openssl-1.1.1h-rys6nl74ap77z7gz56lsypiakqcwjthn
==> Installing apr-util-1.6.1-ptk46cxr7wn5wg5gko6sadfj6542euo4
==> No binary for apr-util-1.6.1-ptk46cxr7wn5wg5gko6sadfj6542euo4 found: installing from source
==> Using cached archive: /apps/opensource/spack/var/spack/cache/_source-cache/archive/b6/b65e40713da57d004123b6319828be7f1273fbc6490e145874ee1177e112c459.tar.gz
==> apr-util: Executing phase: 'autoreconf'
==> apr-util: Executing phase: 'configure'
==> apr-util: Executing phase: 'build'
==> apr-util: Executing phase: 'install'
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/apr-util-1.6.1-ptk46cxr7wn5wg5gko6sadfj6542euo4
==> Installing cmake-3.18.4-5hvxjokut4ye3rirskek5simi63k6lwq
==> No binary for cmake-3.18.4-5hvxjokut4ye3rirskek5simi63k6lwq found: installing from source
==> Fetching https://spack-llnl-mirror.s3-us-west-2.amazonaws.com/_source-cache/archive/59/597c61358e6a92ecbfad42a9b5321ddd801fc7e7eca08441307c9138382d4f77.tar.gz
######################################################################## 100.0%
==> cmake: Executing phase: 'bootstrap'
==> cmake: Executing phase: 'build'
==> cmake: Executing phase: 'install'
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/cmake-3.18.4-5hvxjokut4ye3rirskek5simi63k6lwq
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/python-3.8.6-mtftamh47q4pgqmjlew7yzl65pfugryq
==> Installing utf8proc-2.4.0-b5eysgxx36riqt42j5po6hmn5hopuuab
==> No binary for utf8proc-2.4.0-b5eysgxx36riqt42j5po6hmn5hopuuab found: installing from source
==> Fetching https://spack-llnl-mirror.s3-us-west-2.amazonaws.com/_source-cache/archive/b2/b2e5d547c1d94762a6d03a7e05cea46092aab68636460ff8648f1295e2cdfbd7.tar.gz
######################################################################## 100.0%
==> utf8proc: Executing phase: 'cmake'
==> utf8proc: Executing phase: 'build'
==> utf8proc: Executing phase: 'install'
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/utf8proc-2.4.0-b5eysgxx36riqt42j5po6hmn5hopuuab
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/py-setuptools-50.3.2-jidexxt5nnojxghtqjnddxccrcclxtwj
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/scons-3.1.2-dp6r2qytaezap546nwge2inoac5ons3n
==> Installing serf-1.3.9-m7ykoawinlbhivx73lgajzqjq4k4k7ne
==> No binary for serf-1.3.9-m7ykoawinlbhivx73lgajzqjq4k4k7ne found: installing from source
==> Using cached archive: /apps/opensource/spack/var/spack/cache/_source-cache/archive/54/549c2d21c577a8a9c0450facb5cca809f26591f048e466552240947bdf7a87cc.tar.bz2
==> serf: Executing phase: 'build'
==> serf: Executing phase: 'install'
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/serf-1.3.9-m7ykoawinlbhivx73lgajzqjq4k4k7ne
==> Installing subversion-1.14.0-gxystzjl4d2xubfv5gz5owga7643gfwl
==> No binary for subversion-1.14.0-gxystzjl4d2xubfv5gz5owga7643gfwl found: installing from source
==> Fetching https://spack-llnl-mirror.s3-us-west-2.amazonaws.com/_source-cache/archive/ef/ef3d1147535e41874c304fb5b9ea32745fbf5d7faecf2ce21d4115b567e937d0.tar.gz
######################################################################## 100.0%
==> subversion: Executing phase: 'autoreconf'
==> subversion: Executing phase: 'configure'
==> subversion: Executing phase: 'build'
==> subversion: Executing phase: 'install'
[+] /apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/subversion-1.14.0-gxystzjl4d2xubfv5gz5owga7643gfwl

加载subversion

module load subversion

创建svn repo,名称为repo01

[thesre@centos8 ~]$ mkdir svnPractice
[thesre@centos8 ~]$ cd svnPractice/
[thesre@centos8 svnPractice]$ svnadmin create --fs-type fsfs repo01
[thesre@centos8 svnPractice]$ ls -A repo01/
conf  db  format  hooks  locks  README.txt

配置repo01

匿名不可访问

[thesre@centos8 svnPractice]$ egrep -v '^#|^\s*$' repo01/conf/svnserve.conf 
[general]
anon-access = none
[sasl]

用户ben可以读写

[thesre@centos8 svnPractice]$ egrep -v '^#|^\s*$' repo01/conf/authz 
[aliases]
[groups]
[repo01:/]
ben = rw

配置ssh隧道

[thesre@centos8 svnPractice]$ tail -1 ~/.ssh/authorized_keys 
command="/apps/opensource/spack/opt/spack/linux-centos7-broadwell/gcc-10.2.0/subversion-1.14.0-gxystzjl4d2xubfv5gz5owga7643gfwl/bin/svnserve -t -r /home/thesre/svnPractice/ --tunnel-user=ben",,no-port-forwarding,no-pty,no-agent-forwarding,no-X11-forwarding ssh-rsa <KEY> [email protected]

用户端配置

用户端

用户端为一台普通Mac,下文将通过命令行访问svn服务器的仓库。

软件安装

同服务器端一样,使用包管理器spack安装

spack install subversion

加载subversion

module load subversion

生成并~/.subversion/conf文件

╭─ben at MacBook Pro in ~ 2021/04/13 - 21:31:51
╰─○ svn co # 本命令触发生成~/.subversion文件夹以及相关配置文件
svn: E205001: Try 'svn help checkout' for more information
svn: E205001: Not enough arguments provided
╭─ben at MacBook Pro in ~/.subversion 2021/04/13 - 21:49:06
╰─○ egrep -v '^#|^\s*$' config 
[auth]
[helpers]
[tunnels]
ssh = /usr/bin/ssh -l thesre -i ~/.ssh/id_rsa --
[miscellany]
[auto-props]
[working-copy]

用户验证

╭─ben at MacBook Pro in ~/.subversion 2021/04/13 - 21:34:11
╰─○ svn info svn+ssh://thesre.cn/repo01
Path: repo01
URL: svn+ssh://thesre.cn/repo01
Relative URL: ^/
Repository Root: svn+ssh://thesre.cn/repo01
Repository UUID: e6289242-9c5b-11eb-b12f-25d094c79126
Revision: 0
Node Kind: directory
Last Changed Rev: 0
Last Changed Date: 2021-04-13 21:26:48 +0800 (Tue, 13 Apr 2021)

╭─ben at MacBook Pro in ~ 2021/04/13 - 21:53:33
╰─○ cd /tmp
╭─ben at MacBook Pro in /tmp 2021/04/13 - 21:53:49
╰─○ svn co svn+ssh://thesre.cn/repo01
Checked out revision 0.
╭─ben at MacBook Pro in /tmp 2021/04/13 - 21:53:53
╰─○ cd repo01 
╭─ben at MacBook Pro in /tmp/repo01 2021/04/13 - 21:54:07
╰─○ echo "This is a test file." > test.txt
╭─ben at MacBook Pro in /tmp/repo01 2021/04/13 - 21:54:12
╰─○ svn add test.txt 
A         test.txt
╭─ben at MacBook Pro in /tmp/repo01 2021/04/13 - 21:54:48
╰─○ svn ci -m "Wow, this is my first file to commit."
Adding         test.txt
Transmitting file data .done
Committing transaction...
Committed revision 1.
╭─ben at MacBook Pro in /tmp/repo01 2021/04/13 - 21:55:14
╰─○ svn info svn+ssh://thesre.cn/repo01
Path: repo01
URL: svn+ssh://thesre.cn/repo01
Relative URL: ^/
Repository Root: svn+ssh://thesre.cn/repo01
Repository UUID: e6289242-9c5b-11eb-b12f-25d094c79126
Revision: 1
Node Kind: directory
Last Changed Author: ben
Last Changed Rev: 1
Last Changed Date: 2021-04-13 21:54:52 +0800 (Tue, 13 Apr 2021)

╭─ben at MacBook Pro in /tmp/repo01 2021/04/13 - 21:55:25
╰─○ 

你可能感兴趣的:(subversion)