{"id":6447,"date":"2024-07-03T12:54:10","date_gmt":"2024-07-03T12:54:10","guid":{"rendered":"https:\/\/really.zonky.org\/?p=6447"},"modified":"2024-07-03T12:54:23","modified_gmt":"2024-07-03T12:54:23","slug":"updating-windows-over-ssh","status":"publish","type":"post","link":"https:\/\/really.zonky.org\/?p=6447","title":{"rendered":"Updating Windows Over SSH"},"content":{"rendered":"\n<p>Well, this is kind of a weird one. But most of the systems I run are Linux-based, and over the years I have &#8216;developed&#8217; a simple script that I run from my main workstation which iterates through all of the systems applying updates. <\/p>\n\n\n\n<p>As non-interactively as possible &#8211; it could even be scheduled to run automatically (although I don&#8217;t for no good reason). <\/p>\n\n\n\n<p>But it had one great weakness &#8211; it didn&#8217;t update my Windows 11 virtual machine. Which wasn&#8217;t a <em>serious<\/em> problem because Windows could and did update itself. But it did result in software installed with <em>winget<\/em> getting left behind.<\/p>\n\n\n\n<p>So I sorted it &#8230;<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install OpenSSH server on Windows: PS: <em>Add-WindowsCapability -Online -Name OpenSSH.Server<\/em> (this might need the version number which is best obtained using <em>Get-WindowsCapability -Online | Where-Object Name -like &#8216;OpenSSH*&#8217;.<\/em><\/li>\n\n\n\n<li>Copy your chosen ssh authentication public key into <em>c:\\users\\${username}\\.ssh\\authorized_keys<\/em> file. <\/li>\n\n\n\n<li>Configure <em>c:\\programdata\\ssh\\sshd_config<\/em> to permit public key authentication (&#8220;PubkeyAuthentication yes&#8221;).<\/li>\n\n\n\n<li>Whilst in the same file, comment out the section with the line beginning &#8220;Match Group administrators&#8221; which whilst makes things less secure did at least work! The section does refer to a file: <em>c:\/ProgramData\/ssh\/administrators_authorized_keys<\/em> but adding to this file didn&#8217;t seem to work for me. <\/li>\n\n\n\n<li>Verify that the daemon is running: PS: <em>get-service -name sshd <\/em>\n<ul class=\"wp-block-list\">\n<li>If it shows as not running, enable with: PS: <em>set-service -name sshd -startuptype &#8216;automatic&#8217;<\/em><\/li>\n\n\n\n<li>And either reboot, or start it manually: PS: <em>start-service -name sshd<\/em><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>At this point you should be able to login with a simple <em>ssh username@hostname<\/em> command. If not you&#8217;ve either left something out, or I have!<\/li>\n<\/ol>\n\n\n\n<p>At this point you should be able to run the relevant update commands :-<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><em>ssh username@hostname UsoClient ScanInstallWait<\/em>. Operating system updates which may or may not work, so I wouldn&#8217;t disable the automatic updates at this point.<\/li>\n\n\n\n<li><em>ssh username@hostname winget upgrade &#8211;all<\/em>. This updates additional software (something I&#8217;ve called &#8220;layered products&#8221; in the past) installed via <em>winget<\/em> (or the Microsoft &#8220;Store&#8221;. This can sometimes stop with a mysterious error but should usually work. <\/li>\n<\/ol>\n\n\n\n<p>No guarantees with this sort of thing!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"695\" height=\"521\" src=\"https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/2022-03-28-peering-at-each-other.jpeg?resize=695%2C521&#038;ssl=1\" alt=\"\" class=\"wp-image-6152\" srcset=\"https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/2022-03-28-peering-at-each-other.jpeg?resize=1024%2C768&amp;ssl=1 1024w, https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/2022-03-28-peering-at-each-other.jpeg?resize=300%2C225&amp;ssl=1 300w, https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/2022-03-28-peering-at-each-other.jpeg?resize=768%2C576&amp;ssl=1 768w, https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/2022-03-28-peering-at-each-other.jpeg?resize=1536%2C1152&amp;ssl=1 1536w, https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/2022-03-28-peering-at-each-other.jpeg?w=1654&amp;ssl=1 1654w, https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/2022-03-28-peering-at-each-other.jpeg?w=1390&amp;ssl=1 1390w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><figcaption class=\"wp-element-caption\">Peering At Each Other<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Well, this is kind of a weird one. But most of the systems I run are Linux-based, and over the years I have &#8216;developed&#8217; a simple script that I run from my main workstation which iterates through all of the systems applying updates. As non-interactively as possible &#8211; it could even be scheduled to run <a href='https:\/\/really.zonky.org\/?p=6447' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false,"_share_on_mastodon":"0"},"categories":[4,209,226],"tags":[2244,2245,2243,2242],"class_list":["post-6447","post","type-post","status-publish","format-standard","hentry","category-it","category-linux-it","category-working-notes","tag-openssh","tag-usoclient","tag-windows-11","tag-winget","category-4-id","category-209-id","category-226-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"share_on_mastodon":{"url":"https:\/\/mstdn.social\/@grumpygrimnir\/112722658141517912","error":""},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1f2KI-1FZ","_links":{"self":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/6447","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6447"}],"version-history":[{"count":2,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/6447\/revisions"}],"predecessor-version":[{"id":6449,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/6447\/revisions\/6449"}],"wp:attachment":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}