sudo 사용자를 추가해서 사용하려면, adduser 혹은 useradd 명령을 사용해서 사용자를 등록 할 수 있다.
새 사용자 등록
먼저 adduser를 사용한 등록은,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# adduser qkboo Adding user `qkboo' ... Adding new group `qkboo' (1000) ... Adding new user `qkboo' (1000) with group `qkboo' ... Creating home directory `/home/qkboo' ... Copying files from `/etc/skel' ... Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for qkboo Enter the new value, or press ENTER for the default Full Name []: Gangtai Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n] y
> *************************************************************************** > NOTICE TO USERS > > This computer system is the private property of its owner, whether > individual, corporate or government. It is for authorized use only. > Users (authorized or unauthorized) have no explicit or implicit > expectation of privacy. > > Any or all uses of this system and all files on this system may be > intercepted, monitored, recorded, copied, audited, inspected, and > disclosed to your employer, to authorized site, government, and law > enforcement personnel, as well as authorized officials of government > agencies, both domestic and foreign. > > By using this system, the user consents to such interception, monitoring, > recording, copying, auditing, inspection, and disclosure at the > discretion of such personnel or officials. Unauthorized or improper use > of this system may result in civil and criminal penalties and > administrative or disciplinary action, as appropriate. By continuing to > use this system you indicate your awareness of and consent to these terms > and conditions of use. LOG OFF IMMEDIATELY if you do not agree to the > conditions stated in this warning. > > ****************************************************************************
systemd 를 사용하면,
1 2
$ sudo systemctl restart sshd.service $ sudo systemctl status sshd.service
upstart를 사용하면,
1
$ sudo service ssh restart
공개키 방식을 이용
일반 패스워드를 사용하는 로그인 방식보다 rsa 키를 이용한 접속이 보다 보안에 좋다. 그리고 일단 한번 설정해 놓으면 편하다.
서버에 /etc/ssh/sshd_config 설정에서 rsa키 사용에 대한 설정이 제대로인지 살펴본다.
1 2
PubkeyAuthentication yes RSAAuthentication yes
ssh 클라이언트
클라이언트에서 공개키 생성을 한다. 키의 크기를 높이려면 -b 옵션으로 1024, 2048, 4096 값을 제시한다.
(CLIENT)$ mkdir ~/.ssh (CLIENT)$ chmod 700 ~/.ssh (CLIENT)$ ssh-keygen -t rsa -b 4096 -C "USER@CLIENT_HOST" Generating public/private rsa key pair. Enter file in which to save the key (/Users/daddy/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/daddy/.ssh/id_rsa. Your public key has been saved in /Users/daddy/.ssh/id_rsa.pub. The key fingerprint is: SHA256:nBbRg+tTnmEbyuqzb0cqeBfzuaj1XOJP3n767Xmj3s0 USER@CLIENT_HOST The key\'s randomart image is: +---[RSA 4096]----+ | .o | | ..o | | .. . | | ..o= | | oS= = | | .B = | | . ..B..o | | . =.+=+= ..o*| | o+Oo.=o++=BE| +----[SHA256]-----+
개인 비밀키와 공개키 파일이 ~/.ssh 폴더에 기본 파일이름 id_rsa.pub, id_rsa.prb 파일로 저장된다.
그리고 클라이언트에서 서버로 ssh 접속을 해본다. 로그인 과정 없이 로그인되면 공개키 방식의 인증이 마무리되ㅓㅇㅆ다.
1
(CLIENT)$ ssh USER@SERVER
개인키 파일을 이용한 로그인
-i 옵션을 이용하면 개인키를 여러개 만들어 두고 서버 마다 달리 로그인 할 수 있다.
1
ssh -i .ssh/개인키 id@host-Name
Root kit
chkrootkit
루트킷 탐지 프로그램
일반적인 루트킷, 커널 기반 루트킷, Worm 까지도 탐지 가능
설치
1
$ sudo apt install chkrootkit
컴파일로 빌드 설치시 http://www.chkrootkit.org/ 에서 다운로드후 빌드한다.
1 2 3
$ tar -zxvf chkrootkit.tar.gz $ cd chkrootkit-0.50 $ make sense
루트킷 실행
1
$ sudo chkrootkit
not infected, not found 가 아닌 경우 잘 살펴보자.
rkhunter
Rootkit이 System에 설치되어 있는지 Check합니다. chkrootkit 에서 검사하지 않는 설정 파일들이나 서버 계정 등 을 검사 하기 때문에 chkrootkit 과 함께 사용하면 좋다.
1
$ sudo apt install rkhunter
설치 시에 MTA(Matil Transfer Agent)인 Postfix가 의존성으로 같이 설치됩니다.
RPi Jessie에서 설치시 rkhunter Invalid SCRIPTWHITELIST configuration option: Non-existent pathname: /usr/bin/lwp-request 경고 발생 lwp-request는 명령행 HTTP 사용자 에이전트로 사용하지 않는다면 > /etc/rkhunter.conf에 있는 SCRIPTWHITELIST /usr/bin/lwp-request 주석 처리 참조: lwp-request