Sunday, February 14, 2016

Subversion on Centos7.

Subversion on Centos7.
Related: SSH, firewall-cmd, selinux.

1. Install svn subversion
[root@ct7-1 ~]# yum -y install subversion

2. Create repo
[root@ct7-1 ~]# mkdir -p /var/svn/repos/roller
[root@ct7-1 ~]# svnadmin create /var/svn/repos/roller
[root@ct7-1 ~]# svn mkdir file:///var/svn/repos/roller/trunk -m "create"

Committed revision 1.
[root@ct7-1 ~]# svn mkdir file:///var/svn/repos/roller/branches -m "create"

Committed revision 2.
[root@ct7-1 ~]# svn mkdir file:///var/svn/repos/roller/tags -m "create"

Committed revision 3.
[root@ct7-1 ~]#

3. Importing source
[root@ct7-1 roller]# wget

[root@ct7-1 roller]# unzip

[root@ct7-1 roller]# svn import /home/roller/roller-trunk file:///var/svn/repos/roller/trunk -m "initial import of roller"

4. Start svnserve daemon
[root@ct7-1 roller]# systemctl start svnserve
[root@ct7-1 roller]# ps -ef | grep svnserve
root     24434     1  0 18:40 ?        00:00:00 /usr/bin/svnserve --daemon --pid-file=/run/svnserve/ -r /var/svn
root     24443 22935  0 18:41 pts/0    00:00:00 grep --color=auto svnserve
[root@ct7-1 roller]#

root@ct7-1 roller]# netstat -tpln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   
tcp        0      0  *               LISTEN      24434/svnserve   

#From other server(ubuntu14) is centos7 svnserve.
young@ubuntu14:~$ telnet 3690
telnet: Unable to connect to remote host: No route to host
#Below is normal
young@ubuntu14:~$ telnet 3690
Connected to
Escape character is '^]'.
( success ( 2 2 ( ) ( edit-pipeline svndiff1 absent-entries commit-revprops depth log-revprops atomic-revprops partial-replay ) ) ) ^CConnection closed by foreign host.

#Gotta check firewall or etc.

5.firewall-cmd --add-port number/protocol
[root@ct7-1 roller]# firewall-cmd --add-port 3690/tcp
[root@ct7-1 roller]#
[root@ct7-1 roller]# firewall-cmd --list-all
public (default, active)
  interfaces: enp0s3 enp0s8
  services: dhcpv6-client ssh
  ports: 3690/tcp
  masquerade: no
  rich rules:
^^ It seems very O.k

young@ubuntu14:~/roller_project$ svn list svn://
svn: E000013: Unable to connect to a repository at URL 'svn://'
svn: E000013: Can't open file '/var/svn/repos/roller/format': Permission denied

#This might be a selinux. So change from enforcing to permissive by issuing command "vi /etc/sysconfig/selinux"
[root@ct7-1 repos]# setenforce 0 #This command will cause immediate effect.
#To keep setenforce 0, just edit like belows.

 [root@ct7-1 repos]# cat /etc/sysconfig/selinux

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# Only change from enforcing to permissive.
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.

#Now finally, we can list and checkout.
young@ubuntu14:~/roller_project$ svn list svn://

young@ubuntu14:~/roller_project$ svn co svn://

#Using ssh
young@ubuntu14:~/test$ svn list svn+ssh://young@
young@'s password:

young@ubuntu14:~/test$ svn co svn+ssh://young@

#Without password, use public key.
young@ubuntu14:~/test$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/young/.ssh/id_rsa):
/home/young/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/young/.ssh/id_rsa.
Your public key has been saved in /home/young/.ssh/
The key fingerprint is:
a7:54:2e:08:5a:9d:fc:c8:9d:7e:18:1d:24:9a:56:a6 young@ubuntu14
The key's randomart image is:
+--[ RSA 2048]----+
|        + .      |
|     o B o       |
|    o E   o      |
|   o + = = .     |
|  .   + S +      |
|       o *       |
|        + .      |
|         .       |
|                 |
young@ubuntu14:~/test$ ls
young@ubuntu14:~/test$ scp /home/young/.ssh/ young@
young@'s password:                                                                                             100%  396     0.4KB/s   00:00   

[young@ct7-1 .ssh]$ mv ~/ ./authorized_keys
[young@ct7-1 .ssh]$ ll
total 4
-rw-r--r--. 1 young young 396 Feb 14 19:33 authorized_keys

[root@ct7-1 young]# chmod 700 .ssh/

#Login Test
young@ubuntu14:~$ ssh young@
Last login: Sun Feb 14 19:46:55 2016 from
[young@ct7-1 ~]$

#Now without password.
young@ubuntu14:~$ svn list svn+ssh://young@

young@ubuntu14:~/co_test$ svn co svn+ssh://young@

#It is very happy when things go smoothly. ^^;