2014-06-27 58 views
0

我已經使用PowerShell腳本安裝了Cygwin。使用PowerShell自動化Cygwin配置

我手動執行以下步驟:

  1. 運行一個新的cygwin的bash shell(的cygwin.bat編輯後),然後輸入:

    mount --change-cygdrive-prefix/
    chmod +r /etc/passwd /etc/group 
    chmod 755 /var 
    
  2. 開始Cygwin的bash shell,然後運行ssh-host-config 。對所有關鍵問題回答「是」。

是否有可能在PowerShell腳本中自動執行這些操作,比如安裝Cygwin,然後在單步執行步驟1和2?

+1

如果你'cd'到cygwin目錄,你可以運行'bash.exe ssh-host-config --yes' 不明白爲什麼你不能只是將其添加到步驟1的底部,在1步中完成所有操作 – mrwhale

+0

如果我運行「bash.exe ssh-host-config - 是「,我得到一個錯誤」術語bash.exe不被識別爲一個cmdlet「,還有一件事是我必須Cygwin.bat文件而不是bash.exe文件 – user1400915

+1

你需要'cd'到'%' cygwinhom e%\ bin',其中所有的可執行文件都是'bash.exe'。您可以將上面的命令添加到您的cygwin.bat文件中以自動生成密鑰 – mrwhale

回答

2

使用此命令:

bash.exe ssh-host-config --yes -u "Cygwinuser" -c "binmode ntsec tty" -w "[email protected]" 
cygrunsrv -S sshd 

後來去Services.msc以檢查服務是否正在運行或不