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 https://github.com/apache/roller/archive/trunk.zip

[root@ct7-1 roller]# unzip trunk.zip

#Importing
[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/svnserve.pid -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 0.0.0.0:3690            0.0.0.0:*               LISTEN      24434/svnserve   

#From other server(ubuntu14)
192.168.56.103 is centos7 svnserve.
young@ubuntu14:~$ telnet 192.168.56.103 3690
Trying 192.168.56.103...
telnet: Unable to connect to remote host: No route to host
#Below is normal
young@ubuntu14:~$ telnet 192.168.56.101 3690
Trying 192.168.56.101...
Connected to 192.168.56.101.
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
success
[root@ct7-1 roller]#
[root@ct7-1 roller]# firewall-cmd --list-all
public (default, active)
  interfaces: enp0s3 enp0s8
  sources:
  services: dhcpv6-client ssh
  ports: 3690/tcp
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:
^^ It seems very O.k

young@ubuntu14:~/roller_project$ svn list svn://192.168.56.103/repos/roller
svn: E000013: Unable to connect to a repository at URL 'svn://192.168.56.103/repos/roller'
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.
SELINUX=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.
SELINUXTYPE=targeted


#Now finally, we can list and checkout.
young@ubuntu14:~/roller_project$ svn list svn://192.168.56.103/repos/roller
branches/
tags/
trunk/



young@ubuntu14:~/roller_project$ svn co svn://192.168.56.103/repos/roller


#Using ssh
young@ubuntu14:~/test$ svn list svn+ssh://young@192.168.56.103/var/svn/repos/roller
young@192.168.56.103's password:
branches/
tags/
trunk/
young@ubuntu14:~/test$

young@ubuntu14:~/test$ svn co svn+ssh://young@192.168.56.103/var/svn/repos/roller


#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/id_rsa.pub.
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
roller
young@ubuntu14:~/test$ scp /home/young/.ssh/id_rsa.pub young@192.168.56.103:/home/young/
young@192.168.56.103's password:
id_rsa.pub                                                                                             100%  396     0.4KB/s   00:00   
young@ubuntu14:~/test$



[young@ct7-1 .ssh]$ mv ~/id_rsa.pub ./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@192.168.56.103
Last login: Sun Feb 14 19:46:55 2016 from 192.168.56.102
[young@ct7-1 ~]$



#Now without password.
young@ubuntu14:~$ svn list svn+ssh://young@192.168.56.103/var/svn/repos/roller
branches/
tags/
trunk/
young@ubuntu14:~$


young@ubuntu14:~/co_test$ svn co svn+ssh://young@192.168.56.103/var/svn/repos/roller




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





No comments:

Post a Comment