show code js

2021年10月14日 星期四

Centos Install Mysql update

 (1)source:

### see: https://dev.mysql.com/downloads/repo/yum/ ###

wget  http://repo.mysql.com/mysql80-community-release-el6-3.noarch.rpm

yum localinstall mysql80-community-release-el6-3.noarch.rpm -y

yum module disable mysql

yum install mysql-community-server -y 

systemctl enable mysqld

systemctl start mysqld

systemctl status mysqld

(2)getpswd:

mysql_secure_installation

grep 'temporary password' /var/log/mysqld.log

login mysql -u root -p, to test and quit

mysql>\s

mysql>quit

(3)set use utf8

nano /etc/my.cnf 

### find:

pid-file=/var/run/mysqld/mysqld.pid

### after add:

-------

init_connect='SET collation_connection = utf8mb4_unicode_ci'

init_connect='SET NAMES utf8mb4'

character-set-server=utf8mb4

#character-set-database=utf8mb4

collation-server=utf8mb4_unicode_ci

skip-character-set-client-handshake

[client]

default-character-set=utf8mb4

[mysql]

default-character-set=utf8mb4

--------

systemctl restart mysqld 

(4)grant(all on db.* to 'ur'@'localhost' identified by `pswd`)

CREATE USER 'ur'@'localhost' IDENTIFIED BY 'pswd';

GRANT ALL PRIVILEGES ON db.* TO 'ur'@'localhost';

flush privileges;

2021年7月20日 星期二

Create git server for self on centos

 :server


1.install

yum install git -y


2.add user

adduser git

passwd git


3.create directory for sample project

su git

cd ~

mkdir project.git

cd project.git

git init --bare


4.create ssh directory and file

cd ..

mkdir .ssh

cd .ssh

touch authorized_keys

chmod 700 ~/.ssh/

chmod 600 ~/.ssh/authorized_keys


5.create ssh key

su root

cd ~

ssh-keygen

scp ~/.ssh/id_rsa.pub git@gitserver:~/.ssh/authorized_keys

# or cat ~/.ssh/id_rsa.pub >> /home/git/.ssh/authorized_keys


:client


1.config

git config --global user.name "Your Name" 

git config --global user.email "Your_Mail@example.com"


2.type1:clone

:server create directory in /home/project.git

git clone git@gitserver:~/project.git

cd project 

touch test.txt

git add --all

git commit -a -m "First Version"

git push origin master


3.type2:create new project

:server create directory in /home/new_project.git

mkdir new_project

cd new_project

git init

git remote add origin git@gitserver:~/new_project.git

touch test.txt

git add --all

git commit -a -m "First Version"

git push origin master

2021年7月18日 星期日

fail2ban

可防範對某一服務的暴力破解或掃描的行為

  1. ready
    install and active firewalld
    install epel-release
  2. install
    yum install -y fail2ban
  3. add /etc/fail2ban/jail.local, can use nano
    [DEFAULT]
    # white list
    ignoreip = 127.0.0.1
    # ban time
    bantime  = 600
    # ho much time to try to maxretry
    findtime = 600
    # try time
    maxretry = 5

    [sshd]
    # [service name]
    enabled = true
  4. active
    systemctl enable fail2ban
    systemctl start fail2ban