윈도우

Babun + sshd

ForceCore 2016. 11. 29. 11:20

http://forcecore.tistory.com/1364


후우 ;;; ㅋㅋ 위 글의 MSYS2와 거의 비슷하게 된다.


되긴 된다. 그런데 진짜 수작업이 필요하다.


우선 ssh-host-config 를 실행한다.

*** Warning: Cannot find required command /usr/bin/getent.

*** Warning: Please (re)install the getent package.

*** ERROR: There is something badly wrong with your cygwin installation.

*** ERROR:

*** ERROR: Please install the missing command(s), and make sure all required

*** ERROR: command are executable.  Otherwise the installation provided by this

*** ERROR: script will fail.

*** ERROR:

*** ERROR: To fix this problem, run {rh}setup.exe and (re)install the

*** ERROR: packages mentioned in the warnings above.

{ ~ }  » pact install getent

이런 에러가 반겨줄테니 pact install getent 로 넘어가자.



*** Info: Generating missing SSH host keys

*** Info: Creating default /etc/ssh_config file

*** Info: Creating default /etc/sshd_config file


*** Info: StrictModes is set to 'yes' by default.

*** Info: This is the recommended setting, but it requires that the POSIX

*** Info: permissions of the user's home directory, the user's .ssh

*** Info: directory, and the user's ssh key files are tight so that

*** Info: only the user has write permissions.

*** Info: On the other hand, StrictModes don't work well with default

*** Info: Windows permissions of a home directory mounted with the

*** Info: 'noacl' option, and they don't work at all if the home

*** Info: directory is on a FAT or FAT32 partition.

*** Query: Should StrictModes be used? (yes/no) no


*** Info: Privilege separation is set to 'sandbox' by default since

*** Info: OpenSSH 6.1.  This is unsupported by Cygwin and has to be set

*** Info: to 'yes' or 'no'.

*** Info: However, using privilege separation requires a non-privileged account

*** Info: called 'sshd'.

*** Info: For more info on privilege separation read /usr/share/doc/openssh/README.privsep.

*** Query: Should privilege separation be used? (yes/no) yes

*** Warning: It appears that you do not have entries for the local

*** Warning: ADMINISTRATORS and/or SYSTEM sids in /etc/group.

*** Warning:

*** Warning: Use the 'mkgroup' utility to generate them or allow "db"

*** Warning: search of group accounts in /etc/nsswitch.conf

*** Warning:

*** Warning: It appears that you do not have an entry for the local

*** Warning: ADMINISTRATORS (group) and/or SYSTEM sids.

*** Warning:

*** Warning: Use the 'mkpasswd' utility to generate it or allow "db"

*** Warning: search of passwd accounts in /etc/nsswitch.conf

*** Warning:

*** ERROR: Problem with LocalSystem or Adminstrator IDs


다시 하면 이렇게 된다. 그래도 /etc/sshd_config 가 생기긴 할 것이다. 여기서 한참 막혀서 멘붕이 오고 MSYS2로 갔었는데, MSYS2에서 sshd를 설치하고 나니 요령이 생겨서 이를 클리어 할 수 있게 된 것이다... 후우.


/etc/sshd_config를 손봐주자.

UsePrivilegeSeparation no               # Default for new installations.

라고 고쳤다.... sandbox는 작동하지 않는다고 하니 반드시 yes, no 둘 중 하나로 바꿔준다. 원래 ssh-host-config 가 해주는 것인데 도중에 에러가나니 뭐 어쩔수 있어야지.


제어판에 들어가서 계정 관리 기능을 연다. cyg_server 라는 데몬용 관리자 권한이 있는 계정을 제어판에서 만들고, ssh라는 사용자 계정도 만든다.


 /usr/bin/cygrunsrv -I sshd -d "CYGWIN sshd" -p /usr/sbin/sshd -a "-D -f /etc/sshd_config" -y tcpip -u cyg_server -w "비밀번호"


이제 문제는 디렉토리 권한 어쩌구저쩌구 하는 오류가 난다는 것이다. 오류가 나긴 나는데 무슨 오류인지 화면에 안 나오니까 문제. babun을 관리자 권한으로 실행을 하고...


/var/log/sshd.log

를 참고해서 에러메시지를 하나씩 디버깅하다보면 될 것이다.


/var/empty must be owned by root and not group or world-writable.

필자는 위와 같은 에러가 나왔다. 관리자권한 babun에서는 chown, chmod가 다 먹히므로 적극 활용하라. chown으로 administrator 를 해주고 chmod 700을 해줬다. 그리고 또... /etc/passwd 수정을 해서 없는 root를 만들어서 넣었다. (administrator 복제해서, administrator만 root로 바꿔주면 된다. 그리고 root 항목이 passwd 파일 첫 줄이 되게 하자.)


그리고 net start sshd, net stop sshd 라고 윈도우 명령어로 services.msc 를 대신할 수 있는데... (리눅스의 systemctl 격), 한글이 깨져서 불쾌할 것이다. 이 때 chcp 65001 명령어를 써보자. (change code page 명령어) 이는 리눅스로 치면 export LANG=en_US.UTF-8 정도의 효과가 있어서 에러가 영어로 출력될 것이다. 그래도 한글이 여전히 깨지긴 한다... 호스트명이라던지...