Cygwin  可以讓 Windows 環境使用 Linux 的 Bash 指令

它也可以架設 SSH Server 後,讓 Client 可以 ssh 遠端登入

首先需安裝 Cygwin

到 cygwin.com 去下載 setup-x86_64.exe 檔

使用命令提示字元執行安裝

setup-x86_64.exe -q -s "http://cygwin.mirror.constant.com" -R "C:\Cygwin" -P "cygunsrv,Base,vim,vim-common,openssh,openssl,wget,unzip,rsync" -C "C:\Cygwin_packages" -l "C:\Cygwin_packages"

說明

-s 到 http://cygwin.mirror.constant.com 下載檔案
-R 安裝於 C:\Cygwin
-P 安裝哪些套件
-C 指定存放下載的檔案
-l 從哪邊安裝套件
-L 本地安裝,假如有第一次的使用 -s XX 後,基本套件不變的情況下

成功裝完的訊息

site: http://cygwin.mirror.constant.com/
Changing gid back to original
running: C:\Cygwin\bin\dash.exe "/etc/postinstall/0p_000_autorebase.dash"
running: C:\Cygwin\bin\dash.exe "/etc/postinstall/0p_update-info-dir.dash"
Changing gid to Administrators
Ending cygwin install

打開 Cygwin64 Terminal

執行設定

ssh-host-config

password=`openssl rand -base64 6` echo -e "yes\nyes\nyes\nyes\n\nno\nyes\n$password\n$password" | ssh-host-config

啟動 sshd (CMD)

net start sshd

系統使用者匯入 (Cygwin64 Terminal)

mkpasswd -u Administrator -l >> /etc/passwd

群組

mkgroup -g Administrators -l >> /etc/group

# 改群組
sed -i 's/197121/544/g' /etc/passwd

 

這樣子就可以 SSH Administrator@xx.xx.xx.xx 了,密碼就是本身系統上的,改了密碼也是可以使用新密碼連線 SSH

# ls -l
-rw-r--r--  1 Administrator Administrators     0 五月 22 14:36 files

 

移除 Cygwin

# sotp sshd
net stop sshd

# 刪除 cygwin
sc delete sshd

# 刪除帳號 sshd cyg_server
net user sshd /del
net user cyg_server /del

#
takeown /f C:\cygwin /r /d y
icacls c:\cygwin /t /grant everyone:F

# 刪除檔案目錄
rmdir /s /q c:\cygwin

Related posts 相關文章
xz liblzma 漏洞後門事件
More...
用 DNSSEC 是為了安全,但如果憑證過期了怎麼辦
More...
使用 dehydrated 安裝 Let’s Encrypt SSL 憑證
More...
使用 certbot 安裝 Let’s Encrypt SSL 憑證
More...

作者

留言

RacterUB 

擇一嗎??

RacterUB 

請問ssh-host-config的設定是要怎麼設置?

    作者

    執行設定的地方,下方,有兩行指令,就是它了

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。