본문 바로가기
Unix.Linux

openssl 설치하기

by 누피짱 2008. 8. 16.
Openssh 설치하기

OS : Ledhat Linux Fedora core4
Openssh : openssh-4.3p2

설치 순서

 1. ssh 버전 확인하기
 2. ssh 다운로드하기
 3. 기존 패키지를 검색해서 삭제
 4. sshd 사용자를 검색해서 없으면 생성
 5. 환경 설정(./configure)
 6. 컴파일/ 설치(make/ make install)
 7. 스크립트 파일/ 인증 파일 복사
 8. 실행파일 링크 걸기
 9. sshd 데몬 시작
10. sshd 데몬 확인
11. sshd 서버가 업그레이드 되었는지 확인
12. system V 계열의 runlevel 설정 (자동 시작 설정)

공식 사이트 : http://www.openssh.org/
한국미러사이트 : ftp://linux.sarang.net/

# lynx www.openssh.com
==> http://openssh.org 사이트에 접속해서 다운 받는다. (openssh-4.3p2.tar.gz)

# tar xvzf openssh-4.3p2.tar.gz -C /usr/local/src
==> /usr/local/src 경로에 압축을 푼다.(-C옵션 : PATH 지정)
 

기존 sshd 삭제


# service sshd status
# service sshd stop
==> 기존에 실행되고 있던 sshd 서비스를 stop 시킨다.

# rpm -qa | grep ssh ==> 기존에 ssh 를 찾아낸다.
openssh-clients-4.0p1-3
openssh-server-4.0p1-3
openssh-askpass-gnome-4.0p1-3
openssh-4.0p1-3
openssh-askpass-4.0p1-3

# rpm -e openssh --nodeps
==> 찾아낸 기존 ssh를 -e옵션으로 --nodeps 의존성 에러 무시하고 삭제시킨다.
# rpm -e openssh-askpass
# rpm -e openssh-askpass-gnome
# rpm -e openssh-server
# rpm -e openssh-clients --nodeps

# rm -rf /etc/ssh ==> ssh 디렉토리도 삭제시킨다.

sshd 사용자 생성

# grep sshd /etc/passwd
# useradd -u 74 -d /var/empty/sshd -s /sbin/nologin sshd
==> useradd -u 25 -d /var/empty -s /bin/false -M sshd
# grep sshd /etc/passwd
==> sshd 라는 사용자가 있는지 확인하고 없으면 생성한다.

-u : uid 74
-d : 홈디렉토리 지정
-s : 사용할 쉘지정 -> /sbin/nologin 은 로그인 할 수 없다.
(ftp: 허용, shell: 허용안함)

환경 설정

# ./configure --help > help.sh
==> help.sh 파일에 configure 내용 복사한다.

# vi help.sh
==> 필요한 옵션을 찾아서 앞에 # 표시를 한다.

# grep ^# help.sh
==> help.sh 파일에서 첫문자가 # 인 행을 보여준다.

#grep ^# help.sh | awk '{print $2}' > config.sh
==> help.sh 파일에서 #로 시작하는 것 중에 2번째 필드부터 뽑아내어 config.sh 에 카피한다.

# vi config.sh
 

#--prefix 설치할 디렉토리 지정
#--sysconfdir 설정파일의 위치 지정
#--with-pam pam 인증 지원
#--with-privsep-user 데몬을 띄울 사용자 지정
#--with-md5-passwords md5 비밀번호 지원

./configure \
--prefix=/usr/local/openssh-4.3p2 \
--sysconfdir=/usr/local/openssh-4.3p2/etc \
--with-zlib=/usr/local/lib \
--with-tcp-wrappers \
--with-pam \
--with-ssl-dir=/usr/local/ssl \
--with-privsep-user=sshd \
--with-md5-passwords


# . config.sh && make && make install

스크립트 파일/ 인증 파일 복사

# cd /usr/local/src/openssh-4.3p2/contrib/redhat/
# install -m 755 sshd.init /etc/init.d/sshd
==> cp sshd.init /etc/init.d/sshd
# install -m 644 sshd.pam /etc/pam.d/sshd
==> cp sshd.pam /etc/pam.d/sshd

/etc/init.d/sshd 스크립트 파일의 설치 경로에 맞게 링크를 걸어준다.
# ln -s /usr/local/openssh-4.3p2 /usr/local/openssh
# ln -s /usr/local/openssh/bin/* /usr/bin
# ln -s /usr/local/openssh/sbin/* /usr/sbin
# rm -rf /etc/ssh
# ln -s /usr/local/openssh/etc/ /etc/ssh

# /etc/init.d/sshd start
# netstat -nat | grep 22

자동 시작 설정(runlevel 설정)

# chkconfig --list | grep sshd
# chkconfig --add sshd

sshd 업그레이드 확인

# cat /etc/issue ==> 로컬 로그인 시 보이는 메시지
# cat /etc/issue.net ==> telnet 접속 시 보이는 메시지
# telnet localhost 22
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
SSH-1.99-OpenSSH_4.3
telnet> quit

접속 테스트

# ssh 192.168.11.130 ==> 192.168.11.130에 접속시(root로 접속)
# ssh linux@192.168.11.130 ==> linux 사용자가 접속시



=============
에러 메시지1

configure: error: *** zlib too old - check config.log ***
Your reported zlib version has known security problems. It's possible your
vendor has fixed these problems without changing the version number. If you
are sure this is the case, you can disable the check by running
"./configure --without-zlib-version-check".
If you are in doubt, upgrade zlib to version 1.2.3 or greater.
See http://www.gzip.org/zlib/ for details.

==> http://www.zlib.net/zlib-1.2.3.tar.gz 다운받아 설치한다.

설치 후 라이브러리 확인

# ldd /usr/local/openssh-4.3p2/bin/ssh
libz.so.1 => /usr/lib/libz.so.1 (0x0074b000)
==> /usr/local/lib 경로가 적용이 안됨.
# LD_LIBRARY_PATH=/usr/local/lib ./config.sh

에러 메시지2

# /etc/init.d/sshd start
Starting sshd:WARNING initlog is deprecated and will be removed in a future release
execvp: 그런 파일이나 디렉토리가 없음 [실패]

==> 실행파일에 링크를 걸어주니 해결되었다.
# ln -s /usr/local/openssh/bin/* /usr/bin
# ln -s /usr/local/openssh/sbin/* /usr/sbin

그래도 문제가 해결되지 않으면 /etc/rc.d/init.d/sshd 파일의 108번정도 줄에 아래와 같이 수정해 준다.

initlog -c "$SSHD $OPTIONS" && success || failure
↓
#initlog -c "$SSHD $OPTIONS" && success || failure    ← 元の行をコメントアウト
$SSHD $OPTIONS && success || failure                  ← 代わりに追加


 


[출처]
Openssh 설치하기|작성자 humanang

댓글