Search code examples
powershellcygwin

Automation of Cygwin configuration with PowerShell


I have installed Cygwin using PowerShell scripting.

I am doing the following step manually:

  1. Running a new cygwin bash shell (after the edit of cygwin.bat) and enter:

    mount --change-cygdrive-prefix /
    chmod +r /etc/passwd /etc/group
    chmod 755 /var
    
  2. Start Cygwin bash shell and run ssh-host-config. Answer yes to all the key generation questions.

Is it possible to automate these things in PowerShell scripts, like installing Cygwin, then doing steps 1 and 2 in a single shot?


Solution

  • Use this command:

    bash.exe ssh-host-config --yes -u "Cygwinuser" -c "binmode ntsec tty" -w "pwd@123"
    cygrunsrv -S sshd
    

    Later go to services.msc to check if the service is running or not