실습> OpenSSH 소스 설치하기
소스 컴파일 장점 : 자신의 입맛에 맞게 서버를 구축할 수 있다.
소스 컴파일 단점 : 어렵고 컴파일 에러가 발생할 가능성이 많고 유지 보수 하기가 어렵다.
환경설정 : ./configure -> Makefile
컴파일 : make
설치 : make install
컴파일 삭제 : make clean or make distclean
ChangeLog : 변화된 내용을 기록
INSTALL : 설치에 대한 정보가 기록
README : 이 패키지에 대한 정보가 기록
공식사이트 : http://www.openssh.com
openssh-8.4p1.tar.gz
1. 소스 다운로드
Server1 ~# mkdir openssh; cd openssh
Server1 openssh# yum -y install wget
Server1 openssh# wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.4p1.tar.gz
2. 압축 해제
Server1 openssh# tar xzf openssh-8.4p1.tar.gz
Server1 openssh# cd openssh-8.4p1
환경설정 옵션은 아래와 같다.
Server1 openssh# ./configure --help
--prefix : 설치 디렉터리
--with-ssl-dir : openssl 디렉터리
--with-privsep-user : 사용자
--with-zlib : 압축 라이브러리
--with-pam : pam 인증 모듈
--with-md5-passwords : MD5 passwords
3. 라이브러리 설치
컴파일에 필요한 개발 라이브러리들을 설치한다.
Server1 openssh-8.4p1# yum -y install pam-devel zlib-devel openssl-devel
4. 환경설정
--help 옵션을 주고 옵션들을 확인한다.
Server1 openssh-8.4p1# ./configure --help
Server1 openssh-8.4p1# ./configure \
--prefix=/usr/local/openssh \
--with-ssl-dir \
--with-privsep-user=sshd \
--with-zlib \
--with-pam \
--with-md5-passwords
:
:
OpenSSH has been configured with the following options:
User binaries: /usr/local/openssh/bin
System binaries: /usr/local/openssh/sbin
Configuration files: /usr/local/openssh/etc
Askpass program: /usr/local/openssh/libexec/ssh-askpass
Manual pages: /usr/local/openssh/share/man/manX
PID file: /var/run
Privilege separation chroot path: /var/empty
sshd default user PATH: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/openssh/bin
Manpage format: doc
PAM support: yes
OSF SIA support: no
KerberosV support: no
SELinux support: no
MD5 password support: yes
libedit support: no
libldns support: no
Solaris process contract support: no
Solaris project support: no
Solaris privilege support: no
IP address in $DISPLAY hack: no
Translate v4 in v6 hack: yes
BSD Auth support: no
Random number source: OpenSSL internal ONLY
Privsep sandbox style: seccomp_filter
PKCS#11 support: yes
U2F/FIDO support: yes
Host: x86_64-pc-linux-gnu
Compiler: cc
Compiler flags: -g -O2 -pipe -Wall -Wextra -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-parameter -Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset -fstack-protector-strong -fPIE
Preprocessor flags: -Iyes -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE
Linker flags: -Lyes -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -fstack-protector-strong -pie
Libraries: -lcrypto -ldl -lutil -lz -lcrypt -lresolv
+for sshd: -lpam
PAM is enabled. You may need to install a PAM control file
for sshd, otherwise password authentication may fail.
Example PAM control files can be found in the contrib/
subdirectory
5. 컴파일
cc : gcc 의 심볼릭 링크
-D : define
-L : 라이브러리 디렉터리 위치 지정
-l : 라이브러리명 지정
-o : 실행파일
-I : 헤더파일 디렉터리 위치 지정
소스 파일들을 make(Makefile 참고)를 이용해서 컴파일한다.
Server1 openssh-8.4p1# make
6. 설치
컴파일된 바이너리 파일들을 시스템에 설치한다.
설치 디렉터리는 --prefix 옵션에 설정한 /usr/local/openssh에 설치된다.
Server1 openssh-8.4p1# make install
Server1 openssh-8.4p1# yum -y install tree
Server1 openssh-8.4p1# tree /usr/local/openssh
/usr/local/openssh
├── bin
│ ├── scp
│ ├── sftp
│ ├── ssh
│ ├── ssh-add
│ ├── ssh-agent
│ ├── ssh-keygen
│ └── ssh-keyscan
├── etc
│ ├── moduli
│ ├── ssh_config
│ ├── ssh_host_dsa_key
│ ├── ssh_host_dsa_key.pub
│ ├── ssh_host_ecdsa_key
│ ├── ssh_host_ecdsa_key.pub
│ ├── ssh_host_ed25519_key
│ ├── ssh_host_ed25519_key.pub
│ ├── ssh_host_rsa_key
│ ├── ssh_host_rsa_key.pub
│ └── sshd_config
├── libexec
│ ├── sftp-server
│ ├── ssh-keysign
│ ├── ssh-pkcs11-helper
│ └── ssh-sk-helper
├── sbin
│ └── sshd
└── share
└── man
├── man1
│ ├── scp.1
│ ├── sftp.1
│ ├── ssh-add.1
│ ├── ssh-agent.1
│ ├── ssh-keygen.1
│ ├── ssh-keyscan.1
│ └── ssh.1
├── man5
│ ├── moduli.5
│ ├── ssh_config.5
│ └── sshd_config.5
└── man8
├── sftp-server.8
├── ssh-keysign.8
├── ssh-pkcs11-helper.8
├── ssh-sk-helper.8
└── sshd.8
9 directories, 38 files
리눅스를 설치할 때 설치되어 있는 openssh* 패키지들을 삭제한다.
Server1 openssh-8.4p1# systemctl stop sshd
Server1 openssh-8.4p1# yum -y remove openssh openssh-server openssh-clients
Server1 openssh-8.4p1# rpm -qa | grep openssh
<-- 아무것도 나오지 않으면 openssh* 패키지들이 잘 삭제된 것이다.
Server1 redhat# rm -rf /etc/ssh
7. 세팅
Server1 openssh-8.4p1# cd contrib/redhat
Server1 redhat# cp sshd.pam /etc/pam.d/sshd
Server1 redhat# cp sshd.init /etc/init.d/sshd
Server1 redhat# chkconfig --add sshd
Server1 redhat# chkconfig --list sshd
Server1 redhat# ln -s /usr/local/openssh/etc /etc/ssh
Server1 redhat# ln -s /usr/local/openssh/bin/* /usr/bin
Server1 redhat# ln -s /usr/local/openssh/sbin/* /usr/sbin
Server1 redhat# ln -s /usr/local/openssh/libexec/* /usr/sbin
8. 데몬 실행
Server1 redhat# vi /etc/ssh/sshd_config
Port 2021
Port 22
PermitRootLogin no
ssh 서비스를 시작한다.
Server1 redhat# /etc/init.d/sshd start
Starting sshd (via systemctl): [ OK ]
Server1 ~# ssh -V
OpenSSH_8.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
9. 서버 접속
Server1 ~# useradd -G wheel limanet
Server1 ~# passwd limanet
putty로 접속해서 ssh가 잘 동작하는지 확인한다.
login as: limanet
limanet@192.168.8.3's password:
Last login: Thu Jan 28 06:47:22 2021 from 192.168.8.1
Server1 ~$ telnet localhost 2021
Trying ::1...
Connected to localhost.
Escape character is '^]'.
SSH-2.0-OpenSSH_8.4 <-- 버전이 8.4가 나오면 설치가 성공!!!
'Linux > SSH' 카테고리의 다른 글
| OpenSSH 소스 삭제하기 (0) | 2021.12.08 |
|---|---|
| OpenSSH 소스 설치 [2] (0) | 2021.12.08 |
| ssh 에 root 접속 금지하기 (0) | 2021.12.08 |
| SSH 포트 변경 & 2개 이상 열기 (0) | 2021.12.08 |
| sshd 설정 파일 설명 (/etc/ssh/sshd_config) (0) | 2021.12.08 |