카테고리 보관물:  IT

리눅스 Shell 및 ssh 계정 잠금 설정

  • 콘솔 및 원격 접속(ssh)시 로그인 실패시 계정 잠금 설정
  • pam_tally.so와 pam_tally2.so은 기본값 및 옵션 차이가 있음
// CentOS 5.X 버전 이하용
# /etc/pam.d/system-auth , /etc/pam.d/password-auth 에 이하 설정 추가

// 3회 입력 실패시 계정이 잠기며 잠금 초기화 간격은 2분, root 계정은 잠기지 않고 로그인이 성공하면 실패 횟수는 초기화
auth required pam_tally.so no_magic_root deny=3 unlock_time=120
account required pam_tally.so no_magic_root reset
// CentOS 6.X 버전 이상부터는 pam_tally2.so를 사용할 수 있으므로 이하 설정 권고
# /etc/pam.d/system-auth , /etc/pam.d/password-auth 에 이하 설정 추가

// 3회 입력 실패시 계정이 잠기며 잠금 초기화 간격은 2분, 기본적으로 root 계정은 잠기지 않고 성공하면 실패 횟수는 초기화됨
// even_deny_root 인수를 사용하게 되면 root 비밀번호 입력 실패시 계정이 잠길 수 있음
auth required pam_tally2.so deny=3 unlock_time=120
account required pam_tally2.so

WordPress 설치(Apache base)

아파치 기반 워드프레스 설치를 진행 해보겠습니다.

설치 환경은 아래와 같습니다.

  • CentOS 7 64bit
  • Apache 2.4
  • php 7.2
  • MariaDB 10.3

1. Apache 설치

1.1 패키지 설치(ssl 설정을 위해 mod_ssl 설치)

# yum install httpd httpd-devel mod_ssl -y

1.2 httpd.conf 설정

<VirtualHost *:80>
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
  DocumentRoot /app/doc/wordpress
  ServerName www.sierracloud.kro.kr
  ServerAlias www.sierracloud.kro.kr
</VirtualHost>

<VirtualHost *:443>
  SSLEngine on
  SSLCertificateFile /etc/pki/tls/certs/ca.crt
  SSLCertificateKeyFile /etc/pki/tls/private/ca.key
  DocumentRoot /app/doc/wordpress
  ServerName www.sierracloud.kro.kr
  ServerAlias www.sierracloud.kro.kr
</VirtualHost>

1.3 ssl.conf (openssl 설정 방법은 https://www.sierracloud.kro.kr/https-%ea%b5%ac%ec%84%b1 참고)

SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key

2. php 설치

# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
# yum install mod_php72w php72w-cli -y
# yum install php72w-bcmath php72w-gd php72w-mbstring php72w-mysqlnd php72w-pear php72w-xml php72w-xmlrpc php72w-process -y

// 설치 버전 확인
# php-v

3. MariaDB 설치

3.1 패키지 설치 ( https://www.sierracloud.kro.kr/mariadb-10-3-%ec%84%a4%ec%b9%98 참고 )

3.2 wordpress 용 계정 및 db 생성

# mysql -u root -p password

> CREATE DATABASE wordpress CHARACTER SET utf8 COLLATE utf8_bin;
> GRANT ALL PRIVILEGES on wordpress.* to wordpress@'localhost' IDENTIFIED BY 'password';
> FLUSH PRIVILEGES;

4. WordPress 설치

4.1 패키지 설치

# wget https://wordpress.org/latest.tar.gz
# tar zxvf latest.tar.gz

# mv wordpress /app/doc/
# mkdir /app/doc/wordpress/wp-content/uploads
# chown -R apache:apache /app/doc/wordpress
# chmod -R 755 /app/doc/wordpress

# cd /app/doc/wordpress
# mv wp-config-sample.php wp-config.php

4.2 DB정보 적용

# vi wp-config.php

define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'wordpress');
/** MySQL database password */
define('DB_PASSWORD', 'password');
/** MySQL hostname */
define('DB_HOST', 'localhost');

4.3 Salt 설정 ( https://api.wordpress.org/secret-key/1.1/salt 접속하여 출력된 텍스트 복사 )

#vi wp-config.php

// 아래 문단을 주석처리 또는 삭제 후 복사한 내용을 붙혀넣기
define( 'AUTH_KEY',         'put your unique phrase here' );
define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
define( 'NONCE_KEY',        'put your unique phrase here' );
define( 'AUTH_SALT',        'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
define( 'NONCE_SALT',       'put your unique phrase here' );

5. 아파치 시작

# systemctl enable httpd
# systemctl start httpd

6. 서버의 IP 또는 URL에 브라우저 정상 접속 확인

MariaDB 10.3 설치

CentOS 7에 MariaDB를 yum을 통해 설치하는 방식입니다.

1. yum repository 경로 설정

# vi /etc/yum.repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

2. 패키지 설치 및 서비스 실행

# yum install MariaDB-client MariaDB-server -y

# systemctl enable mariadb
# systemctl start mariadb

3. mariadb 접속 확인 및 비밀번호 설정

# mysql -u root

> use mysql;

> update user set password = password('새비밀번호') where user='root';
// 비밀번호 설정('') 넣어야 됨
> flush privileges;