install-openssh-with-cygwin-on-windows-10html
原本windows10上已經有內置的openssh
,我可能愛折騰不肯意使用內置的,因此使用cygwin
從新安裝了一個ssh服務.git
openssh
和openssl
sshd
和ssh-host-config
默認的服務名衝突解決ntsec
和建立默認的cyg_server
來運行sshd
服務net start cygsshd
ssh
ssh
注意:cygwin使用的是windows的用戶和權限,因此默認
/etc/
下是沒用passwd
和group
等文件的,不要太驚訝。github開始我也沒用搞明白,並且
ssh-host-config
中建立一個cyg_server
用戶是真實的windows帳戶,可是須要組策略纔可以看到,這個用戶用來啓動sshd
服務的,並且不能用來登錄windows,由於是一個令牌用戶,在組策略>計算機配置>windows配置>安全設置>本地策略>用戶權限分配> 建立一個令牌對象中看到。windows
假設你已經安裝了cygwin
,使用cygwin安裝openssh和openssl詳情看參考:安全
how-to-get-ssh-command-line-access-to-windows-7-using-cygwin/bash
警告:sshd service is already installed.oracle
出現sshd service is already installed.的問題是由於windows 10內置了一個openssh,形成了衝突,如今只須要修改cygwin安裝的openssh中的默認的sshd服務名稱。dom
路徑: C:/cygwin64/bin/sshd-host-config
(32位的有所區別,找不到用everything搜索一下啊)ssh
修改: service_name=sshd 爲 service_name=cygsshd (cygsshd自定義的)測試
修改完以後從新執行ssh-host-config
,上面的問題解決.
下面是運行中的截圖.
建議使用默認的cyg_server
,沒用必要從新自定義,我當時也是好奇,搞得走了不少彎路。
也能夠重啓一下系統,服務會自動啓動
net start cygsshd # cygsshd是自定義的service_name
# 或者使用cygwin運行
cygrunsrv -S cygsshd
複製代碼
選擇生成用戶的
RSA
口令就好了,RSA
比較經常使用,其它的不是很經常使用。
# 刪除sshd服務, sshd時默認的服務名,若是你定義了,輸入你的服務名
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
# 這裏刪除的是windows上的用戶
net user sshd /delete
# 若是ssh-host-config配置過程當中沒用使用cyg_server,請替換爲你自定義的名字
net user cyg_server /delete
複製代碼
若是設置權限不行,刪除sshd.log和empty文件夾.
chown <USERNAME> /var/log/sshd.log
chown -R <USERNAME> /var/empty
chown <USERNAME> /etc/ssh*
chmod 755 /var/empty
chmod 644 /var/log/sshd.log
複製代碼
Installing Cygwin and Starting the SSH Daemon
how-to-get-ssh-command-line-access-to-windows-7-using-cygwin/