DBILITY

window 10 cygwin , ssh install & uninstall 본문

os/windows

window 10 cygwin , ssh install & uninstall

DBILITY 2016. 9. 25. 13:49
반응형
  1. www.cygwin.com에서 64비트용 setup파일을 다운로드합니다.
    다운로드 경로는 c:\cygwin64으로 설정합니다.
  2. 내려받은 setup-x86_64.exe를 실행합니다.
  3. 다음을 눌러 Root Install / Local Package Directory를 동일하게 설정합니다.(예,C:\cygwin64)
  4. Direct Connection / Download Site 선택 후 Package선택 화면이 나타납니다.
    아래와 같이 검색하여 선택 후 다음 클릭, Resolving Dependencies 확인 후 다음을 클릭하면 다운로드가 시작됩니다.
    openssh,openssl,wget등만 선택되었지만,다른 package도 필요하면 선택하면 됩니다.


  5. 시작메뉴에서 Cygwin64 Terminal을 관리자권한으로 실행합니다.
    ( 또는 C:\cygwin64\bin\mintty.exe, C:\cygwin64\Cygwin.bat )
    한글출력을 위해 제목표시줄에서 오른쪽클릭 아래와 같이 설정합니다.
  6. vi .bashrc
    110~115라인 주석을 해제,저장 후 다시 로그인 합니다.


  7. ssh 설정을 진행합니다.
    ROOKIE@ROOKIE-PC ~
    $ ssh-host-config -y
    
    *** Info: Generating missing SSH host keys
    ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519
    *** 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) yes
    
    *** 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
    *** Info: Note that creating a new user requires that the current account have
    *** Info: Administrator privileges.  Should this script attempt to create a
    *** Query: new local account 'sshd'? (yes/no) yes
    *** Info: Updating /etc/sshd_config file
    
    *** Query: Do you want to install sshd as a service?
    *** Query: (Say "no" if it is already installed as a service) (yes/no) yes
    *** Query: Enter the value of CYGWIN for the daemon: [] ntsec
    *** Info: On Windows Server 2003, Windows Vista, and above, the
    *** Info: SYSTEM account cannot setuid to other users -- a capability
    *** Info: sshd requires.  You need to have or to create a privileged
    *** Info: account.  This script will help you do so.
    
    *** Info: It's not possible to use the LocalSystem account for services
    *** Info: that can change the user id without an explicit password
    *** Info: (such as passwordless logins [e.g. public key authentication]
    *** Info: via sshd) when having to create the user token from scratch.
    *** Info: For more information on this requirement, see
    *** Info: https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-nopasswd1
    
    *** Info: If you want to enable that functionality, it's required to create
    *** Info: a new account with special privileges (unless such an account
    *** Info: already exists). This account is then used to run these special
    *** Info: servers.
    
    *** Info: Note that creating a new user requires that the current account
    *** Info: have Administrator privileges itself.
    
    *** Info: No privileged account could be found.
    
    *** Info: This script plans to use 'cyg_server'.
    *** Info: 'cyg_server' will only be used by registered services.
    *** Query: Do you want to use a different name? (yes/no) no
    *** Query: Create new privileged user account 'ROOKIE-PC\cyg_server' (Cygwin name: 'cyg_server')? (yes/no) yes
    *** Info: Please enter a password for new user cyg_server.  Please be sure
    *** Info: that this password matches the password rules given on your system.
    *** Info: Entering no password will exit the configuration.
    *** Query: Please enter the password:
    *** Query: Reenter:
    
    *** Info: User 'cyg_server' has been created with password '*********'.
    *** Info: If you change the password, please remember also to change the
    *** Info: password for the installed services which use (or will soon use)
    *** Info: the 'cyg_server' account.
    
    
    *** Info: The sshd service has been installed under the 'cyg_server'
    *** Info: account.  To start the service now, call `net start sshd' or
    *** Info: `cygrunsrv -S sshd'.  Otherwise, it will start automatically
    *** Info: after the next reboot.
    
    *** Info: Host configuration finished. Have fun!
    
    ROOKIE@ROOKIE-PC ~
    $ net start sshd
    CYGWIN sshd 서비스를 시작합니다..
    CYGWIN sshd 서비스가 잘 시작되었습니다.
    
    ROOKIE@ROOKIE-PC ~
    $ ssh-user-config
    *** Query: Shall I create a SSH2 RSA identity file for you? (yes/no) yes
    *** Info: Generating /home/ROOKIE/.ssh/id_rsa
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    *** Query: Do you want to use this identity to login to this machine? (yes/no) yes
    *** Info: Adding to /home/ROOKIE/.ssh/authorized_keys
    *** Query: Shall I create a SSH2 DSA identity file for you? (yes/no) yes
    *** Info: Generating /home/ROOKIE/.ssh/id_dsa
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    *** Query: Do you want to use this identity to login to this machine? (yes/no) yes
    *** Info: Adding to /home/ROOKIE/.ssh/authorized_keys
    *** Query: Shall I create a SSH2 ECDSA identity file for you? (yes/no) yes
    *** Info: Generating /home/ROOKIE/.ssh/id_ecdsa
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    *** Query: Do you want to use this identity to login to this machine? (yes/no) yes
    *** Info: Adding to /home/ROOKIE/.ssh/authorized_keys
    *** Query: Shall I create a (deprecated) SSH1 RSA identity file for you? (yes/no) yes
    *** Info: Generating /home/ROOKIE/.ssh/identity
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Saving key "/home/ROOKIE/.ssh/identity" failed: unknown or unsupported key type
    *** Query: Do you want to use this identity to login to this machine? (yes/no) yes
    *** Info: Adding to /home/ROOKIE/.ssh/authorized_keys
    cat: /home/ROOKIE/.ssh/identity.pub: No such file or directory
    
    *** Info: Configuration finished. Have fun!
    
    ROOKIE@ROOKIE-PC ~
    $ ssh -v localhost
    OpenSSH_7.3p1, OpenSSL 1.0.2j  26 Sep 2016
    debug1: Reading configuration data /etc/ssh_config
    debug1: Connecting to localhost [::1] port 22.
    debug1: Connection established.
    debug1: identity file /home/ROOKIE/.ssh/id_rsa type 1
    debug1: key_load_public: No such file or directory
    debug1: identity file /home/ROOKIE/.ssh/id_rsa-cert type -1
    debug1: identity file /home/ROOKIE/.ssh/id_dsa type 2
    debug1: key_load_public: No such file or directory
    debug1: identity file /home/ROOKIE/.ssh/id_dsa-cert type -1
    debug1: identity file /home/ROOKIE/.ssh/id_ecdsa type 3
    debug1: key_load_public: No such file or directory
    debug1: identity file /home/ROOKIE/.ssh/id_ecdsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /home/ROOKIE/.ssh/id_ed25519 type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /home/ROOKIE/.ssh/id_ed25519-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_7.3
    debug1: Remote protocol version 2.0, remote software version OpenSSH_7.3
    debug1: match: OpenSSH_7.3 pat OpenSSH* compat 0x04000000
    debug1: Authenticating to localhost:22 as 'ROOKIE'
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: algorithm: curve25519-sha256@libssh.org
    debug1: kex: host key algorithm: ecdsa-sha2-nistp256
    debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug1: Server host key: ecdsa-sha2-nistp256 SHA256:urLoIwSpoeDLJgz/ufx+IHT59qBt2ffA78jayJ7c4yM
    The authenticity of host 'localhost (::1)' can't be established.
    ECDSA key fingerprint is SHA256:urLoIwSpoeDLJgz/ufx+IHT59qBt2ffA78jayJ7c4yM.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
    debug1: rekey after 134217728 blocks
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: rekey after 134217728 blocks
    debug1: SSH2_MSG_NEWKEYS received
    debug1: Skipping ssh-dss key /home/ROOKIE/.ssh/id_dsa - not in PubkeyAcceptedKeyTypes
    debug1: SSH2_MSG_EXT_INFO received
    debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey,password,keyboard-interactive
    debug1: Next authentication method: publickey
    debug1: Offering RSA public key: /home/ROOKIE/.ssh/id_rsa
    debug1: Server accepts key: pkalg rsa-sha2-512 blen 279
    debug1: Authentication succeeded (publickey).
    Authenticated to localhost ([::1]:22).
    debug1: channel 0: new [client-session]
    debug1: Requesting no-more-sessions@openssh.com
    debug1: Entering interactive session.
    debug1: pledge: network
    debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0

※ 삭제방법
1. 관리자권한으로 명령창을 실행합니다.
2. sshd서비스를 다음과 같이 중지하고, 삭제합니다.
   sc stop "sshd"
   sc delete "sshd"

3. 설치시 추가된 사용자를 확인 후, 삭제합니다.
   net user cyg_server /delete
   net user sshd /delete

4. regedit를 관리자 권한으로 실행 후 메뉴->편집->찾기-> cygwin입력 후 검색하여 모두 삭제합니다.
5. 설치디렉토리를 삭제합니다.

 

반응형
Comments