반응형

Window에서 SSH 서버를 실행하는 방법은 여러가지가 있지면, 여기서는 cygwin을 이용한 데몬(윈도우 서비스) 사용 방법을 알아 본다. 먼저 관리자 권한으로 cygwin 실행해서 아래의 설치 절차를 진행한다.

 

다른 블로그 글을 참고해서 설치한 절차

  • cygwin을 관리자 모드로 실행

  • ssh-host-config 명령 실행해서 모두 yes로 답

  • Privileges는 no로 답 (굳이 특수 권한이 필요하지 않다면)

  • 서비스로 설치

 

작업 절차

  1. 일단, Cygwin의 setup.exe 에서 openssh를 선택해서 설치한다.

 

  1. Cygwin 셸(관리자 모드 - 윈도우 서비스 설치를 위해)을 실행하고서 ssh-host-config명령을 실행한다. 그리고 모든 질문에 yes 로 대답한다. 마지막에 CYGWIN 옵션을 물을 때는 "ntsec"을 지정한다. 버전마다 조금씩 달라질 수 있지만 디폴트 옵션을 계속 선택하면 된다.

 

$ ssh-host-config
Generating /etc/ssh_host_key
Generating /etc/ssh_host_rsa_key
Generating /etc/ssh_host_dsa_key
Generating /etc/ssh_config file
Privilege separation is set to yes by default since OpenSSH 3.3.
However, this requires a non-privileged account called 'sshd'.
For more info on privilege separation read /usr/share/doc/openssh/README.privsep.

Should privilege separation be used? (yes/no) yes
Warning: The following function requires administrator privileges!
Should this script create a local user 'sshd' on this machine? (yes/no) yes
Generating /etc/sshd_config file
Added ssh to C:WINDOWSsystem32driversetcservices


Warning: The following functions require administrator privileges!

Do you want to install sshd as service?
(Say "no" if it's already installed as service) (yes/no) yes

Which value should the environment variable CYGWIN have when
sshd starts? It's recommended to set at least "ntsec" to be
able to change user context without password.
Default is "ntsec". CYGWIN=ntsec

The service has been installed under LocalSystem account.
To start the service, call `net start sshd' or `cygrunsrv -S sshd'.

Host configuration finished. Have fun!

 

  1. 제어판의 서비스에서 Cygwin sshd를 끄고 켤 수 있으며, Cygwin 셸에서는 cygrunsrv -S sshd 명령이나, 윈도우 명령창에서 net start sshd으로 마찬가지로 sshd를 켤 수 있다.

 

  1. 외부에서 접속이 안될 때는 윈도우의 방화벽을 확인하고, 22포트를 열어준다. (윈도우 방화벽에서)

 

사용/접속 방법

 

  • 윈도우 서비스 메뉴를 보면 openssh도 서비스 모드가 존재하는데 여기서는 cygwin 사용한다. (직접 작업을 할 필요 없고 아래와 같이 확인 가능하다는 의미)

 

  • SSH 접속을 하고 싶은 계정의 home 디렉토리에서 가서 .ssh 디렉토리 설정

  • SSH Key (id_rsa, id_rsa.pub) 생성: ssh-config -t rsa 명령으로

  • authorized_keys 파일에 접속을 원하는 클라이언트의 Public Key를 등록해 준다.

 

  • ps 명령으로 확인 가능

 

 

삭제 방법

 

# Remove sshd service
cygrunsrv --stop sshd
cygrunsrv --remove sshd

# Delete any sshd or related users (such as cyg_server) from /etc/passwd
#   (use your favorite editor)

# Delete any sshd or related users (such as cyg_server) from the system
net user sshd /delete
net user cyg_server /delete





참고 자료

 

http://kwon37xi.egloos.com/2496478

 

http://www.howtogeek.com/howto/41560/how-to-get-ssh-command-line-access-to-windows-7-using-cygwin/ 문서를 참조한다.

 

http://old.nabble.com/openssh-5.1p1-3---ssh-host-config-dependency-and-permission-issues-p19865924.html





Posted by Hey Jerry
,