rsh 사용을 위한 설정과 사용법

개발 2010. 10. 14. 15:56

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

"manager서버"는 rsh를 실행하는 서버이다.
"target서버"는 원격지의 서버로 관리당하는 서버이다.


1. 일단 target서버에 rsh, rsh-server의 설치가 필요하다.
    yum명령으로 간단하게 설치할수 있다.

$ yum search rsh
================================================== Matched: rsh ==================================================
lam.i386 : LAM (Local Area Multicomputer) 프로그래밍 환경.
lam.x86_64 : LAM (Local Area Multicomputer) 프로그래밍 환경.
fonts-sinhala.noarch : Fonts for Sinhala
openssh.x86_64 : The OpenSSH implementation of SSH protocol versions 1 and 2
rsh.x86_64 : 원격 액세스 명령에 사용되는 클라이언트 (rsh, rlogin, rcp).
rsh-server.x86_64 : 원거리 접속 명령어 (rsh, rlogin, rcp) 에 사용되는 서버.
tcp_wrappers.i386 : TCP 데몬에 사용되는 wrapper로서 활동하는 보안 도구.
tcp_wrappers.x86_64 : TCP 데몬에 사용되는 wrapper로서 활동하는 보안 도구.

$ yum install tcp_wrappers.x86_64

(확인방법)

$ rpm -qa | grep rsh
rsh-0.17-38.el5
rsh-server-0.17-38.el5


2. 이제 Centos 자체에서 설정을 할 차례이다.
target서버에서 어떠한 ip를 허용할 것인지 지정하도록 한다.

/root/.rhosts 에 허용할 ip를 적는다.
/home1/irteam/.rhosts 에 허용할 ip를 적는다.
10.24.9.xxx

.rhosts파일은 보안을 위해서 퍼미션을 변경한다.

# chmod 600 .rhosts


3. 이제 rsh와 rlogin을 활성화( on ) 시킨다.

# chkconfig --level 35 rlogin on
# chkconfig --level 35 rsh on
(활성화 확인)
# chkconfig --list | grep rlogin
# chkconfig --list | grep rsh

4. xinetd 에서도 활성화 한다.

# vi /etc/xinetd.d/rlogin
# default: on
# description: rlogind is the server for the rlogin(1) program.  The server \
#       provides a remote login facility with authentication based on \
#       privileged port numbers from trusted hosts.
service login
{
        socket_type             = stream
        wait                    = no
        user                    = root
        log_on_success          += USERID
        log_on_failure          += USERID
        server                  = /usr/sbin/in.rlogind
        disable                 = no  ( 요기를 no로 변경 )
}

rsh, rlogin을 추가해준다.

# vi /etc/securetty에 rsh, rlogin을 추가해준다.
console
vc/1
vc/2
#vc/3
#vc/4
#vc/5
#vc/6
#vc/7
#vc/8
#vc/9
#vc/10
#vc/11
tty1
tty2
#tty3
#tty4
#tty5
#tty6
#tty7
#tty8
#tty9
#tty10
#tty11
rsh
rlogin

그리고 xinetd를 재시작한다.

# service xinetd restart

5. 비밀번호 없이 들어오도록  수정

# vi /etc/pam.d/rlogin
#%PAM-1.0
# For root login to succeed here with pam_securetty, "rlogin" must be
# listed in /etc/securetty.
auth       sufficient   pam_nologin.so
auth       sufficient   pam_securetty.so
auth       sufficient   pam_env.so
auth       sufficient   pam_rhosts_auth.so
auth       include      system-auth
account    include      system-auth
password   include      system-auth
session    optional     pam_keyinit.so    force revoke
session    include      system-auth


# vi /etc/pam.d/rsh
#%PAM-1.0
# For root login to succeed here with pam_securetty, "rsh" must be
# listed in /etc/securetty.
auth       sufficient   pam_nologin.so
auth       sufficient   pam_securetty.so
auth       sufficient   pam_env.so
auth       required     pam_rhosts_auth.so
account    include      system-auth
session    optional     pam_keyinit.so    force revoke
session    include      system-auth

설정이 완료 되었다.


manager 서버에서는 아래와 같이 실행해면된다.
cmd 부분을 따옴표로 감싸야 파라미터도 같이 전달된다.

# rsh target-ip cmd
# rsh masyncserver 'touch /home1/iretam/test.txt'

참고로 rsh는 보안에 취약하므로 주의해서 사용해야 한다.



: