Ref

https://github.com/geofront-auth/geofront

 

geofront-auth/geofront

Simple SSH key management service. Contribute to geofront-auth/geofront development by creating an account on GitHub.

github.com

Colonize automation for geofront server

# colonize.py
import os
import json

# create public key
create_pub_key = os.popen("ssh-keygen -y -f /var/lib/geofront/id_rsa > /var/lib/geofront/id_rsa.pub").read()

# load server list
with open("/opt/geofront/server/server.json", 'r') as f:
        ds = json.load(f)

hosts = list()
for k, v in ds.items():
        hosts.append(k)

# get password from env variable
pw = os.environ['PASSWORD']

# start coping to remote authorized_key
for host in hosts:
        remote = ds[host]["account"]+"@"+ds[host]["ip"]
        try:
                cmd = "sh /ssh-copy-id.sh " + remote + " " + pw
                print("Executing ssh-copy-id on: " + host)
                exec_cmd = os.popen(cmd).read()
        except:
                e = os.popen("echo "+remote+" >> /failed_ssh_host.log").read()
                print("Exception error: check /failed_ssh_host.log")

date = os.popen("date").read()

 

# ssh-copy-id.sh
#!/bin/bash
remote=$1
pw=$2

# spawn & expect: enter for command line interaction
#spawn ssh-copy-id -o StrictHostKeyChecking=no -i /var/lib/geofront/id_rsa.pub $remote
expect << EOF
spawn ssh-copy-id -i /var/lib/geofront/id_rsa.pub $remote
expect {
    "(yes/no)?" { send "yes\n"; exp_continue }
    "password:" { send "$pw\n"; exp_continue }
    eof
}

- 서버 설정


1. Database 외부 연결 설정


MariaDB [(none)]> USE mysql;

MariaDB [(none)]> UPDATE user SET Host='%' IDENTIFIED BY 'password';

MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'sqlUsername'@'%' IDENTIFIED BY 'password';

MariaDB [(none)]> FLUSH PRIVILEGES;

※모든 IP 허용 > Host 값 %로 설정 (특정 IP 허용 > '111.222.333.%'

※필요 시 my.cnf 값 수정

  [~@~]# vi /etc/my.cnf (or /etc/mysql/my.cnf)

  #bind-address = 127.0.0.1 (코멘트)


# systemctl restart mariadb



2. 서버 측 iptables 룰 편집

 mysql port: 3306

# iptables -L

# iptables -I INPUT -p tcp -m tcp --dport 3306 -j ACCEPT

# service iptables save

# systemctl restart iptables



- VS 2015 설정


1. MySQL for Visual Studio 설치



※필요 시 VS 프로젝트에 Reference 추가를 위해 .NET connector 설치





※Advanced... 옵션을 통해 각 항목 설정


※붉은 x 표시 > 연결 끊김

'Database' 카테고리의 다른 글

Installing Oracle Database 12c on the ubuntu linux  (0) 2015.04.29

+ Recent posts