2015년 7월 9일 목요일

리눅스 스크립트를 만들고 확인할 사항(오류방지를 위해서)

sh -x 사용sh -x 스크립트경로/스크립트이름.sh

사용자 환경에 맞추어 실행을 시뮬레이션 해보아야 한다.

실행시킬 사용자로 반드시 해볼 것을 추천.

2015년 2월 26일 목요일

이클립스 + jeus 5 + 오라클 프로젝트 구성


[출처:http://blog.naver.com/PostView.nhn?blogId=yruyo&logNo=80105185296]
출처에서 가져온 내용을 임의로 편집을 하겠습니다.
회사에 제우스5 라이센스가 많이 놀고 있어서 제우스를 써야한다.ㅜㅜ
제우스의 성능 차이가 톰캣과는 넘사벽일까? 

아래를 참조해서 이클립스에 제우스 플러그인을 설치를 완료한다.
http://kyjmagic.tistory.com/entry/JEUS-60%EA%B3%BC-Eclipse-35-%EA%B0%88%EB%A6%B4%EB%A0%88%EC%98%A4-%EC%97%B0%EB%8F%99

Eclipse+Tomcat 셋팅에서 JEUS 셋팅 갈아타기 

1. JEUS WEBMain.xml 설정
일반적으로 JEUS 폴더의 config 폴더내에 있다.
<?xml version="1.0" encoding="UTF-8"?><jeus-system xmlns="http://www.tmaxsoft.com/xml/ns/jeus" version="6.0">
   <node>
      <name>WAS</name>
      <engine-container>
         <name>container1</name>
         <id>9</id>
         <base-port>9841</base-port>
         <command-option>-Xms256m -Xmx1024m -XX:MaxPermSize=256m</command-option>
         <user-class-path>/source/app/war/WEB-INF/message:/source/app/war/WEB-INF/conf</user-class-path>
         <engine-command>
            <type>servlet</type>
            <name>engine1</name>
         </engine-command>
         <sequential-start>true</sequential-start>
      </engine-container>
      <class-ftp>true</class-ftp>
      <sequential-start>true</sequential-start>
      <enable-webadmin>true</enable-webadmin>
      <system-logging>
         <level>INFO</level>
         <handler>
            <file-handler>
               <name>fileHandler</name>
               <level>INFO</level>
               <valid-day>1</valid-day>
            </file-handler>
         </handler>
      </system-logging>
   </node>
   <resource>
      <data-source>
         <database>
            <vendor>oracle</vendor>
            <export-name>jdbc/oracle</export-name>
            <data-source-class-name>oracle.jdbc.pool.OracleConnectionPoolDataSource</data-source-class-name>
            <data-source-type>ConnectionPoolDataSource</data-source-type>
            <database-name>데이터베이스명</database-name>
            <port-number>1521</port-number>
            <server-name>서버 아이피</server-name>
            <user>데이터베이스 계정</user>
            <password>계정 비밀번호</password>
            <property>
               <name>driverType</name>
               <type>java.lang.String</type>
               <value>thin</value>
            </property>
            <connection-pool>
               <pooling>
                  <min>20</min>
                  <max>40</max>
                  <step>5</step>
                  <period>3600000</period>
               </pooling>
               <check-query>select 1 from dual</check-query>
            </connection-pool>
         </database>
      </data-source>
   </resource>
   <application>
      <name>web</name>
      <path>/source/app/war</path>
      <deployment-type>COMPONENT</deployment-type>
      <web-component/>
      <deployment-target>
         <target>
            <engine-container-name>WAS_container1</engine-container-name>
            <web-context-group>
               <name>MyGroup</name>
            </web-context-group>
         </target>
      </deployment-target>
   </application>
</jeus-system>


우선 command-option 부분은 Eclipse에 Tomcat Plug-In을 붙여서 사용했던 분들은 아시겠지만
Eclipse의 Window>Preferences에서 Tomcat>JVM Settings>Append to JVM Parameters에
해당하는 부분이며 user-class-path 부분은 Tomcat>JVM Settings>Classpath에 해당하는 부분이다. 위의 2곳을 Eclipse에 동일하게 맞춰서 engine-container을 셋팅해 주고 data-source 부분은
oracle 이면 거의 대부분이 동일한데 database-name, port-number, server-name, user, password
이정도만 확인해 줘도 충분할 것이다. 각 사항은 직관적이니 설명은 스킵한다. 그리고 application 부분에서는 JEUS WebAdmin에서 디플로이하면 설정되는 부분인데 구분하기 위한 name을 설정하고
실제 소스의 home 디렉토리를 path에 설정하면 WEBMain.xml 설정은 끝.


2. 개별 엔진의 WEBMain.xml 설정
<?xml version="1.0"?>
<web-container xmlns="http://www.tmaxsoft.com/xml/ns/jeus" version="6.0">
    <context-group>
        <group-name>MyGroup</group-name>
        <webserver-connection>
            <http-listener>
                <listener-id>http1</listener-id>
                <port>8091</port>
                <thread-pool>
                    <min>10</min>
                    <max>10</max>
                    <step>1</step>
                </thread-pool>
            </http-listener>
<!--
            <webtob-listener>
                <listener-id>webtob1</listener-id>
                <port>9900</port>
                <output-buffer-size>8192</output-buffer-size>
                <thread-pool>
                   <min>30</min>
                   <max>30</max>
                   <step>1</step>
                   <max-idle-time>30000</max-idle-time>
                </thread-pool>
                <webtob-address>localhost</webtob-address>
                <registration-id>MyGroup</registration-id>
            </webtob-listener>
-->
        </webserver-connection>
        <logging>
            <access-log>
                <handler>
                    <file-handler>
                        <name>handler1</name>
                        <valid-day>1</valid-day>
                    </file-handler>
                </handler>
            </access-log>
        </logging>
    </context-group>
</web-container>


JEUS의 config 폴더의 개별 엔진의 폴더에 들어가면 위에서 설명한 같은 이름의 WEBMain.xml이
존재하는데 열어보면 내용은 차이가 있다. webtob를 셋팅을 하지 않기로 했으니 주석처리가 되어있
으며 1번에서 설명한 WEBMain.xml의 web-context-group/name과 개별 엔진의 WEBMain.xml의 group-name이 같은지 확인하고 사용할 port 번호를 port에 설정한다. 보통 80이지만 개발임으로 8091로 셋팅했다.


3. 소스의 WEB-INF의 jeus-web-dd.xml  설정
보통 JEUS WebAdmin에서 디플로이 시키면 자동으로 소스의 WEB-INF에 jeus-web-dd.xml가 생기는거 같은데 JEUS WebAdmin을 사용하지 않는다면 아래를 참조해서 만들어주면 된다.

<?xml version="1.0" encoding="UTF-8"?>
<jeus-web-dd xmlns="http://www.tmaxsoft.com/xml/ns/jeus">
    <context-path>/portal</context-path>
    <enable-jsp>true</enable-jsp>
    <auto-reload>
        <enable-reload>false</enable-reload>
        <check-on-demand>false</check-on-demand>
    </auto-reload>
</jeus-web-dd>


여러 옵션이 있지만 기본적으로 두고 사용 될 context path를 context-path에 지정해 준다.




4. 소스의 WEB-INF의 web.xml 설정
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee">
  <display-name>iKEP Portal</display-name>
                               .
                               .
                               .
   <resource-ref>
      <description>iKEP portal DB Connection</description>
      <res-ref-name>jdbc/oracle</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
    </resource-ref>
    <jsp-config>
      <jsp-property-group>
      <url-pattern>*.jsp</url-pattern>
      <el-ignored>true</el-ignored>
      </jsp-property-group>
    </jsp-config>

</web-app>

보통 시작이 <web-app>로 되어있는데 JEUS에서 사용하려면 <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"> 라고 해줘야 한다. 그렇지 않으면 jboot 시에 web-app 어쩌구 저쩌구 에러 메세지를 발견할 수 있다. res-ref-name는 1번 설명에서 data-source/database/export-name 에서 같은 이름인지 확인을 해야 하고 jsp에서 jstl을 이용해서 코딩한 경우 낮은 버전을 호환하도록 하기 위해 jsp-config 이하 부분을 모두 추가해 주도록 한다.




5. lib 확인
Tomcat>lib 에서 사용했던 라이브러리 파일들은 그대로 복사하여서 JEUS 폴더의 lib>application 폴더로 복사해 주면 되고 나머지 사용된 라이브러리 파일들은 소스의 WEB-INF>lib로 모두 위치시켜 주면 된다. 소스의 WEB-INF>lib의 라이브러리 파일과 JEUS 폴더의 lib>application의 라이브러리 파일들이 서로 겹치지 않는지 확인해 주면 된다.

>>>당연한 이야기지만 ojdbc14.jar파일이 있어야 한다.



이정도면 어느정도 기본적인 셋팅 방법이라고 할 수 있겠는데 그래도 안된다 싶으면 JEUS의 로그 파일을 살펴봐서 에러에 따라 처리를 해주는 것이 좋을 것이다. 그 이외의 문제는 정말 정말 정말 검색 또는 아는 사람에게 물어보는게 현명할 듯. 정 안되면 티맥스소프트에 문의하면 원격으로도 지원이 된다고 하나. 어디까지나 제우스를 구입해야지 지원이 가능할거라 예상된다. -ㅅ-a
[출처] Eclipse+Tomcat 셋팅에서 JEUS 셋팅 갈아타기|작성자 이루



추가적인 오류해결법 >>>
http://openwdev.blogspot.kr/2013/09/jeus-jeusmainxml-jsp-compile.html

jeus에서 JEUSMain.xml 잘못 세팅으로 인한 jsp compile 안되는 현상 발생

War배포시 잘되는제 프로젝트를 직접 배포 할경우 다음과 같은 오류 발생.
War배포가 아닌 직접 프로젝트로 배포 할경우 WebContent까지 경로를 잡아줘야 한다.

[2013.09.12 11:03:04][1][b068] [container1-10] fail to parse jsp file : /WebContent/main.jsp

--------------JEUSMain.xml-----------
<application>
      <name>test_web</name>
      <path>D:\test_web\</path>   <===== 여기를       <path>D:\test_web\WebContent</path> 잡아줘야 한다.(난 아마추어다 -_-)
      <deployment-type>COMPONENT</deployment-type>
      <web-component/>
      <deployment-target>
         <target>
            <engine-container-name>XXX_container1</engine-container-name>
            <web-context-group>
               <name>MyGroup</name>
            </web-context-group>
         </target>
      </deployment-target>
   </application>
---------------------------------------

2015년 1월 27일 화요일

centos nfs server 설정 MacOSX client 설정

centos 7 서버
 
[root@dlp ~]#yum -y install nfs-utils
[root@dlp ~]#vi /etc/idmapd.conf
# line 5: uncomment and change to your domain name
Domain =server.world
 
[root@dlp ~]#vi /etc/exports 
 
# write settings for NFS exports
/home 10.0.0.0/24(rw,no_root_squash)
 
[root@dlp ~]#restart rpcbind
[root@dlp ~]#start nfs-server
[root@dlp ~]#start nfs-lock
[root@dlp ~]#start nfs-idmap
[root@dlp ~]#enable rpcbind
[root@dlp ~]#enable nfs-server
[root@dlp ~]#enable nfs-lock
[root@dlp ~]#enable nfs-idmap  
 
 클라이언트 마운트
리눅스에 마운트한다면 링크를 참조 http://www.server-world.info/en/note?os=CentOS_7&p=nfs&f=2
 
맥에 nfs를 마운트하기 위해서 간단한 명령어를 사용하면 가능하다.
 
sudo mount -t nfs -o resvport 서버아이피-호스트네임:/data /Users/폴더/

sudo diskutil unmount /Users/폴더/

하지만 centos 7이라면 방화벽을 오픈해야 정상적으로 동작한다.

firewall-cmd --direct --add-rule ipv4 filter INPUT 0 -p tcp --dport 2049 -j ACCEPT
firewall-cmd --direct --add-rule ipv4 filter INPUT 0 -p udp --dport 2049 -j ACCEPT

firewall-cmd --permanent --zone=public --add-port=2049/tcp
firewall-cmd --permanent --zone=public --add-port=2049/udp

firewall-cmd --reload

난 방화벽이 필요없다면 이것이 답이다.

systemctl stop firewalld

2015년 1월 16일 금요일

오라클 유저생성/삭제 덤프 임포트

DROP USER [삭제할 유저명] CASCADE;

SELECT SID,SERIAL# FROM V$SESSION WHERE USERNAME = '[타겟이 될 계정명]';

ALTER SYSTEM KILL SESSION '[SID],[SERIAL]';

sid와 serial을 ,로 구분해서 함께 넣어야 한다.

테이블 스페이스 이름 조회
SELECT TABLESPACE_NAME, STATUS, CONTENTS FROM DBA_TABLESPACES;
테이블 스페이스 생성(NEW_USER_DATA)
CREATE TABLESPACE NEW_USER_DATA
DATAFILE '/somedir/userdata_data.dbf' size 1500M AUTOEXTEND ON NEXT 200M
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO

유저 생성
CREATE USER NEW_USER identified BY NEW_USER_PASSWD
DEFAULT tablespace NEW_USER_DATA
TEMPORARY tablespace TEMP
profile DEFAULT QUOTA unlimited On NEW_USER_DATA;

alter user NEW_USER quota unlimited on NEW_USER_DATA;

GRANT CONNECT TO NEW_USER;
GRANT resource TO NEW_USER;
GRANT DBA TO NEW_USER;
GRANT Unlimited tablespace TO NEW_USER;


imp userid=new_user/new_user file='test.dmp' fromuser=test  touser=new_user  ignore='y'



테이블스페이스명이 변경되어야 하는 경우 아래의 링크를 참고해서 변경이 가능하다.
혹시 몰라 본문을 복해서 붙여넣는다.
출처 : database.sarang.net

<질문 내용>
test 테이블스페이스에 있는내용을
exp userid=test/test file=test.dmp
위와 같이 받은뒤

다른서버의 새로 생성된 테이블 스페이스에다가
 imp userid=test2/test2 file='test.dmp' fromuser=test  touser=test2  ignore='y'
적용하였더니....
데이터는 제대로 들어가는데 테이블 스페이스가
이전 test 로 되어있습니다.

새로 들어가는 test2로 적용이 되게 하고 싶은데 어떡해야 하나요?
부탁드립니다.

<답변 내용 1>
안녕하세요.. 이런 건이 있다니 반갑네요 ..
저도 이런 프로젝트가 있어서.. 해봤었거든요..

테이블스페이스에 쿼터뺏고, 그런거 다 안됩니다. 상식적으로 생각해봐도 안되죠.. ㅋㅋㅋ...  저도 삽질해 봤습니다.. .

또, show=y .. 이거 안됩니다.. 그렇게 해서 스크립트를 뽑으면, 제대로된 스크립트가 안나오죠...  많이 고쳐야 됩니다.

아래 내용은 제가 싸이트에서 해본 내용입니다. 1000% 보장합니다.

옵션 중에 indexfile 라는 게 있습니다. 요건 역시 스크립트만 뽑아주는 건데요.. 테이블과 인덱스 생성스크립트 만 뽑아줍니다.
프로시저라던가, 시퀀스, 뷰  등등은. .. index 나 테이블에 딸려있는 오브젝트 들이죠.. 하여.. 테이블과 인덱스만 틀을 갖춰 놓으면, import 시 ignore=y 옵션으로 데이타만 때려넣으면 알아서 다 들어갑니다.


그럼, 방법을 설명드리지요..

먼저, 이관해야할 DB에서 export 로 dmp 파일을 생성합니다.
그리고, export 받은 dmp 파일에서 스크립트를 뽑아내는 것이죠.
export 받은  dmp 파일을 intranet.dmp 라고 합시다.

imp system/manager file=intranet.dmp fromuser=intranet touser=intra  indexfiles=index.sql constraints=y full=y  log=intra.log

이렇게 하면,  index.sql 이라는 스크립트를 하나 떨궈줍니다. 실제로 improt 를 하는 게 아니라 스크립트를 만드는 겁니다.
index.sql 을 열어보면. 테이블과 인덱스를 생성하는 스크립트가 주욱 있습니다. 그곳에다가 오브젝트가 위치할 테이블스페이스 명을 다 바꿔줍니다. 오브젝트 앞의 유저이름도 주의하세요. intranet.employee 같은 거요. 유저명도 바꿔주셔야 되지요.. .
 더블쿼테이션(") 은.. vi 같은데서 일괄적으로 지워 주시고요. row 몇건 이런건 앞에 -- 로 주석처리 해줍니다. editplus 같은데서 하시면 편해요 ^^;;

이런 것도 알려드려야 되나?? 알고 계실듯 하지만..
:1,$s/"//g   이런식으로요..
:1,$s/row/--row/g  대충이런식으로 바꾸면, 처리되지요..
그리고 스크립트만 남겠지요. 물론 테이블스페이스를 모두 바꾼...

그리고, import 할 유저로 로긴해서, index.sql 을 돌려줍니다.
그럼 테이블과 인덱스가 생성되겠지요. 원하시는 테이블스페이스에 말이죠. 물론, 미리 테이블스페이스는 다 만들어 놓으셨겠지요..

그리고, 마지막으로 intranet.dmp 파일에서 데이타만 때려 넣으면 되겠지요...

imp system/manager file=intranet.dmp fromuser=intranet touser=intra constraints=y commit=y ignore=y log=intra.log  direct=y

commit 옵션은 롤백세그먼트가 작다면, 써주시구요.. ,direct 옵션은 써주면 빠르더라구요..
ignore 옵션이 가장 중요합니다. 데이타만 때려넣어야 되니까요..
확인해 보시면 스크립트에 변경한 테이블스페이스로 제대로 들어가 있을 겁니다.

도움이 되셨길 빕니다..

<답변 내용 2>

import할때 스크립트 옵션을 사용하여 일단 스트립트만 받은다음 스크립트를 열어 테이블 스페이스를 수정한후 스크립트를 수행합니다.(껍데기만 생성됨) 그후에 ignore=y로 한번더 import하여 자료를 붓습니다.

1. 원본 exp받기
    # exp aaa/aaa123 file=aaa.dmp log=aaa.log buffer=40960
   
2. index script 생성하기
    - indexfile Option을 이용하여 index script 생성
    # imp aaa/aaa123 file=aaa.dmp indexfile=index.sql  fromuser=aaa touser=aaa(tablespace 부분 수정)
3. 수정한 sql문을 실행시켜서 테이블 만들기/index만들기   
4. exp받아둔 파일로 진짜 import 하기/ignore=y하여 에러안나게
   껍데기만 만들어진 상태에서 ignore없이하면 또 만들려다 에러남
   # imp aaa/aaa123 file=aaa.dmp buffer=40960 log=imp0522.log commit=y fromuser=aaa touser=aaa ignore=y
유성호(ysh74)님이 2003-09-29 22:52:07에 작성한 댓글입니다.
또 다른 방법으로는

새로운 서버에 test2 라는 유저계정을 만드신후 default tablespace를 새로운 tablespace 로 정합니다.   그리고 alter user test2 quota 0M on test 라고 해 주시면 모든 테이블이 test2 테이블 스페이스로 들어 갑니다.

단 기존의 테이블에 LONG 이나 RAW 같은 데이타 타입이 들어있으면 안됩니다.


주의사항 : 오라클 11g 부터는 expdp로 익스포트와 임포트를 진행해야한다.

2015년 1월 15일 목요일

CentOS 7 오라클 11g 설치 변경사항

기존에 정리된 사이트도 있지만
최근에 검색한 참고페이지 : http://blog.beany.co.kr/archives/3198

여기에서 변경해야하는 부분.

커널 파라미터 수정 후에 적용시키는 방법이 변경된 듯 하다. 아래와 같다.
sysctl -f --system
커널 파라미터는 설치중간에 반영시켜도 다시 읽어서 문제가 없긴하다.

항상 문제가 되던 패키지  pdksh-5.2.14-30

wget ftp://ftp.pbone.net/mirror/www.whiteboxlinux.org/whitebox/4/en/os/x86_64/WhiteBox/RPMS/pdksh-5.2.14-30.x86_64.rpm
rpm -Uvh --nodeps ./pdksh-5.2.14-30.x86_64.rpm

이렇게 설치하려고 하였으나 ksh-* 패키지와 충돌 메시지가 출력되며 설치가 안된다.
대처는
rpm -e ksh-20100621-16.el6.x86_64
충돌하는 패키지를 지우는 방법이 있고

어떤이는
yum install ksh
설치하라고 해서 설치확인만 하고 무시하고 진행했더니 설치가 된다.

설치할 때 항상 .bash_profile에 SID 설정하고 그대로 진행해야하지만
하다보면 마음이 변해서 SID를 또 바꾸게 되는데
설치 끝에 가서 실행시키는 스크립트인지 뭐가 잘못되면서
dbca가 제대로 실행이 안되는 문제가 보인다.

수동으로 dbca를 실행시키려면
{ORACLE_BASE}/product/11g/bin/dbca를 실행시키면 된다.

마지막으로 포트개방 방법이 변경되었다.
기존에 iptables를 사용했었는데
sudo iptables -L  조회만 가능하다.
기존방법은 사용불가(iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT)

$ sudo firewall-cmd --zone=public --add-port=1521/tcp --permanent
$ sudo firewall-cmd --reload 

위 명령어로 잘 된다.

2015년 1월 13일 화요일

Windows - Installing an SSH server

출처: https://bscb.cornell.edu/about/resources/windows-installing-ssh-server

잘 정리되어있어 그대로 복사.
윈도우즈에 sshd 설정해놓으면 터널링을 이용하기에 좋다.
유저 추가는 윈도우즈 유저를 그대로 가져오는 방식이기에
유저에 패스워드가 설정되어 있어야한다.

Installing an SSH server on Windows 2000 or Windows XP

Cygwin is a collection of free software tools originally developed by Cygnus Solutions to allow various versions of Microsoft Windows to act somewhat like a UNIX system. It is a Linux-like environment for Windows that consists of two parts - a DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial POSIX system call functionality and a collection of tools.

Install Cygwin and the SSH server

In order to install the OpenSSH sshd server on Windows you will need to do the following:
  1. Log on to Windows as an Administrator
  2. Create the folder C:\Cygwin
  3. Download Cygwin's setup.exe from here and save it in C:\Cygwin
  4. Launch the installer by double clicking on C:\Cygwin\setup.exe
    1. It is possible that you will get an Open File - Security Warning
    2. Simply click the Run button if you do
  5. Click Next
  6. Select Install from Internet and click Next
  7. At the Choose Installation Directory screen:
    1. Choose C:\Cygwin as the Root Directory
    2. Select Install For: All Users (RECOMMENDED)
  8. Click Next
  9. Choose C:\Cygwin as the Local Package Directory
  10. Click Next
  11. At the Select Connection Type menu - choose Direct Connection unless you know you are using another setting
  12. Click Next
  13. Choose a Download Site
  14. Click Next
  15. At the Cygwin Setup - Select packages Screen - click on the View button for "Full" view (the default view is "Category").
    1. Scroll down to find the package "openssh: The OpenSSH server and client programs" in the Package column. Click on the word "skip" so that a checked box appears in the Bin? column
    2. Scroll down to find the package "tcp_wrappers: Tools providing host-based access restrictions on tcp services" in the Package column. Click on the word "skip" so that a checked box appears in the Bin? column.
    3. Scroll down to find the package "vim: Vi Mproved - enhanced vi editor" in the Package column. Click on the word "skip" so that a checked box appears in the Bin? column.
  16. Click Next to begin the installation process
  17. Click Finish to close the installer

Configuring the SSH server

  1. Right click on My Computer --> Properties --> Advanced --> Environment Variables
  2. The upper portion contains a list of User variables and the lower portion contains a list of System variables. Click the New button underneath the System variables section to add a new system variable and add:
    1. Variable name: cygwin
    2. Variable value: ntsec
    3. Click OK to create the variable
    4. Click OK to close the Edit User Variable screen
    5. Click OK to close the Environmental Variables screen
    6. Click OK to close the System Properties screen
  3. Open a Cygwin window by launching C:\Cygwin\cygwin.bat - a black screen will appear. At the prompt type: ssh-host-config
    1. When the script asks "Should privilege separation be used?", answer yes
    2. When the script asks to "Create a new local account 'sshd'?", answer yes
    3. When the script asks to "Install sshd as a service?", answer yes
    4. When the script asks to "Enter the value of CYGWIN for the daemon:", answer ntsec

Starting the SSH server

  1. To start the sshd service, open a Cygwin window and type one of the following commands (they both accomplish the same thing):
    1. net start sshd
    2. cygrunsrv --start sshd
  2. In order to harmonize Windows user information with Cygwin - open a Cygwin window and type in the following commands (separately):
    1. mkpasswd --local > /etc/passwd
    2. mkgroup --local > /etc/group

Configure the Windows Firewall

If you are running Windows XP Service Pack 2 or Service Pack 3 - you have to configure the Windows Firewall to allow SSH traffic through it
  • Click on Start --> Control Panel --> Windows Firewall --> Exceptions Tab
  • Click the Add Port... button
  • Name: SSH
  • Port Number: 22
  • TCP
  • Click OK to add the SSH exception to the firewall
  • Click OK to close the Windows Firewall screen

Executing UNIX commands within a DOS window

If you want to be able to execute certain UNIX commands within a DOS command prompt window, do the following:
  • Right click on My Computer --> Properties --> Advanced --> Environment Variables
  • In the System variables section, highlight the Path variable and click the Edit button
  • Append the System variable by adding ;C:\Cygwin\bin to the end of the existing variable string
  • Click OK to close the Edit System Variable screen
  • Click OK to close the Environmental Variables screen
  • Click OK to close the System Properties screen

Names with spaces

If you have a Windows username that contains a space, you could expand the [space] into \[space] or use quotes. For example: If the Windows username is Ezra Cornell, you could log in with either of the following commands:
  • ssh Ezra\ Cornell@localhost
  • ssh "Ezra Cornell"@localhost

Reinstalling the SSH server

If you re-install Cygwin or run ssh-host-config when sshd is already installed, ssh-host-config will not ask for CYGWIN value. In that case, you have to stop and remove the sshd service, and then run the ssh-host-config script again.
  • cygrunsrv --stop sshd
  • cygrunsrv --remove sshd
  • ssh-host-config (enter the information as indicated above)
  • cygrunsrv --start sshd