0
I'm running Windows server 2012 R2. I have a cygwin_config file that I run inside cygwin with excpect cygwin_config command. The file configures my ssh_config and sshd_config. Is there any way to run this script from my powershell so I wouldn't need to go into cygwin to run it? I have tried a few things but without any success such as:
$file= Get-ChildItem C:\Cygwin\home\Administrator\cygwin_config | Select-Object
$cmd=Start-Process C:\Cygwin\bin\mintty.exe $file
It tried to open mintty.exe but it immideately closed the mintty.exe. If nothing else helps I guess I will need to create the users that ssh-host-config needs by powershell.
I also created a file that has expect /path/to/cygwin_config and saved it as .exe file. After double clicking on it I get an error popup: "Windows cannot access the specified device,path, or file. You may not have the appropriate permissions to access them." I have tried to run things as admin and changed permissions in directory but nothing works for that one.
My cygwin_config:
#!/bin/expect -f
spawn ssh-host-config
set timeout 20
expect {
"Should StrictModes be used? (yes/no)" { send "no\r" }
}
set timeout 5
expect {
"new local account 'sshd'? (yes/no)" { send "yes\r" }
}
expect {
"Do you want to install sshd as a service?" {send
"yes\r";exp_continue }
"Enter the value of CYGWIN for the daemon:" { send " \r"; }
}
set timeout 5
expect {
"Do you want to use a different name? (yes/no)" { send "no\r";
exp_continue }
"Create new privileged user account" { send "yes\r";
exp_continue }
"Please enter the password" { send "pwd\r";
exp_continue }
"Reenter:" {send "pwd\r";
exp_continue }
}
[EDIT] Got over the windows popup error by changing permissions for the file from the properties(gave full rights to admin). But it still won't work because the app can't run on my pc: "This app can't run on your PC" So that solution goes to the trash bin.
Thank you, I was able to get a bit forward on my quest. Now instead when its trying to run it, it won't succeed because ssh-host-config is not existing according to the powershell. `C:\Cygwin\bin\expect.exe : couldn't execute "ssh-host-config": no such file or directory At C:\Users\Administrator\Desktop\cygwin.ps1:1 char:1
Mira, it is not the powershell that is reporting that ssh-host-config does not exist, this message originates from the expect command (and is only passed through by the powershell). You may want to create a shell script in Cygwin that sets the required environment variables (PATH in particular) and call ssh-host-config from within that shell script, and finally call that shell script with the spawn command from your expect script. – Uwe Mayer – 2018-05-29T13:44:58.830