-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provision-openssh.ps1 fails when run from autounattend #28
Comments
That's a strange error. It seems the I would try to execute a simple script, and go from there. |
Hey Rui, all the other scripts are working, and, at least in the provisioner step, the script gets successfully executed until the line mentioned above. Edit: to add on to that, it works when lines 70-74 are commented out in provision-openssh.ps1 -- this is really weird!? that command works flawlessly in all the different user / privilege / shells - foo combinations, that I tried. |
To confirm, if you are running that script from packer, which is using the ssh communicator, that might terminate the ssh session when it uninstalls the built in ssh server, which might explain why packer ends up failing. You should change the packer communicator to winrm. If you are running that script from autounatted, I have no idea why that uninstall might be failing, maybe opening the vm console (which would have a desktop session open in the administrator account), and manually execute it there might give some clue. The autounatend is running as the administrator user account. It runs in a auto logon desktop session which you can see if you connect to the launched packer vm. |
Hey Rui, thanks for your answers! Packer's communicator has always been set to WinRM so far. Packer builds run through, that script just outputs a premature Exit Code 0, so to speak and thus never executes the steps after installing rsync. Hope that was understandable. |
There are extra limitations imposed on applications that execute from a remote session, so sometimes, one has to reshort to run the commands indirectly from a high privileged scheduled task (e.g. Run as system). So maybe that's why running from packer might be failing. But, I was expecting things to run without problems from autounatend because those command run locally as you would manually do, so that's quite puzzling to understand why it's failing. Which windows 10 iso URL are you using? Maybe I can try to reproduce that problem here. |
I have been using win10_21h2_EnglishInternational_x64.iso with Windows 10 Pro as Edition, as well as 17763.737.190906-2324.rs5_release_svc_refresh_SERVERESSENTIALS_OEM_x64FRE_en-us_1.iso for Windows 2019 Server Essentials. Both installed without OpenSSH. My (working) workaround thus far is: running provision-pwsh, -openssh and -psremoting in SynchronousCommands in the specialize pass in my Autounattend and provision-winrm as well as provision-vmtools in the oobe pass. I came to try this as I read, that oobe will be run as the user, while specialize will be run as SYSTEM - apparently openssh need SYSTEM permissions, while vmtools (though I added qemu-ga to that script) and winrm need user permissions. Edit: which, heads up, results in the insecure vagrant public key being placed into: |
Thanks for the clarifications. Maybe, now, when OpenSSH is installed as a windows feature it does something differently than what is available at https://github.com/PowerShell/Win32-OpenSSH/releases. I say "now", because at some point, I've tried to remove the OpenSSH windows feature (using what is in this repo) and it worked, so, it seems something changed in the mean time. Unfortunately, I do not use or have access the Windows versions/flavors that you've mentioned. I can only use the ones that are in this repository. Disclaimer: Be aware that this repository is intended to be used to create a vagrant box, that's why some things (like adding the public vagrant key and default vagrant user/password) are configured to work as vagrant normally expects them. YMMV when you take them out-of-context. |
Well, fwiw, I could reproduce the behavior with the Win10 Evaluation 20H2 you are using in this repo. My autounattend is a tiny bit different, and I use proxmox as a builder, so the error must be lying somewhere with these. |
Its indeed strange, but I'm afraid I cannot reproduce it. I've just tried Win10 Evaluation 20H2 and it worked here. It uninstalled the OpenSSH Windows feature without any problem. I'm doing this in a Ubuntu 22.04 with the kvm/libvirt builder. |
I noticed OpenSSH not being installed even though the builds ran through fine. In the setupact.log everything seems to be fine. When run manually the script runs through without problems as well. I don't know how to get more verbose logging :/
My workaround so far is to comment it out in provision-autounattend.ps1 and run it as a packer provision step.
Edit: oh, that fails as well with curious reasons for doing so:
After switching on the debug flags, it shows the script silently exiting after
as said, manually, there are no hickups. I wonder which account actually runs the script, a) in the autoattend.xml b) as a packer provisioner step.
The text was updated successfully, but these errors were encountered: