WSL Ubuntu, is there an easy way to have bash start automatically on Windows startup?Ubuntu 18.04 on WSL cron daemon not running after rebootHow to uninstall ubuntu-desktop in Bash on WindowsHow to change default user in WSL Ubuntu bash on Windows 10Ubuntu/ Windows Shared Folder (using WSL)How do I get WSL to start my login shell by default?Ubuntu on Windows 10: Docker vs WSLReduce size of a WSL installation (Ubuntu 18 on Windows 10)Running Ubuntu in the new Windows 10 using WSL Windows System for Linux (not hyper-V)Why can I use my RSA keys with the Git Bash app but not with Ubuntu WSL on my Windows machine?

Template not provided using create-react-app

Is it safe to drive from Prague to Salzburg during winter?

Does the "stand your ground" law regarding shooting an intruder apply when the door of the dwelling was not locked?

Would italians refer to an American or foreign woman as Signora?

Why isn't current carried through a vacuum?

Is Irish buttermilk different

A single word for "not allowed to be changed" or "must be this way"

Why couldn't Rick just use a micro sun to power his car?

What does 36.000€ mean?

What should be done if I suspect a player is using weighted dice?

What should be done when the theory behind a PhD thesis turns out to be wrong?

What are the factors that decide on whether you die instantly or get knocked out in PUBG?

Accidentally likened superior to assailant

Why do right-wing parties generally oppose the legalization of marijuana?

Preposition with спросить

How do professors and lecturers learn to teach?

Is it possible to stall a plane so badly that the nose refuses to go down due to lack of airspeed?

GVS similarity in cognate words other Germanic Languages

Switch to a specific input source in OS X in Catalina with AppleScript

Do Adventure cards count towards "number of instant and sorcery cards in your graveyard"?

How do electric hot water heaters explode and what can be done to prevent that from happening?

Can two moons have intersecting orbits yet be guaranteed not to collide?

Why are green parties so often opposed to nuclear power?

Does it make sense to use strict equality constraint in optimization?



WSL Ubuntu, is there an easy way to have bash start automatically on Windows startup?


Ubuntu 18.04 on WSL cron daemon not running after rebootHow to uninstall ubuntu-desktop in Bash on WindowsHow to change default user in WSL Ubuntu bash on Windows 10Ubuntu/ Windows Shared Folder (using WSL)How do I get WSL to start my login shell by default?Ubuntu on Windows 10: Docker vs WSLReduce size of a WSL installation (Ubuntu 18 on Windows 10)Running Ubuntu in the new Windows 10 using WSL Windows System for Linux (not hyper-V)Why can I use my RSA keys with the Git Bash app but not with Ubuntu WSL on my Windows machine?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









0


















I have a question about the WSL version of Ubuntu. Is there an easy way to have bash start automatically when Windows starts and pass a command to it to start the SSH server? So that the SSH server runs all the time when Windows runs.










share|improve this question































    0


















    I have a question about the WSL version of Ubuntu. Is there an easy way to have bash start automatically when Windows starts and pass a command to it to start the SSH server? So that the SSH server runs all the time when Windows runs.










    share|improve this question



























      0













      0









      0


      1






      I have a question about the WSL version of Ubuntu. Is there an easy way to have bash start automatically when Windows starts and pass a command to it to start the SSH server? So that the SSH server runs all the time when Windows runs.










      share|improve this question














      I have a question about the WSL version of Ubuntu. Is there an easy way to have bash start automatically when Windows starts and pass a command to it to start the SSH server? So that the SSH server runs all the time when Windows runs.







      windows-subsystem-for-linux






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 28 at 12:16









      PF92PF92

      32 bronze badges




      32 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          0



















          (( update this works on WSL 2))



          Solution 1 use VBE script.



          Click on Start and search for shell:startup.
          also you can go manually to:




          C:Users<< username >>AppDataRoamingMicrosoftWindowsStart
          MenuProgramsStartup
          note: change username with your own username.




          now create a new file : sshserver.vbe and add fallow content:



          Set ws = CreateObject("Wscript.Shell") 
          ws.run "wsl -d Ubuntu -u root service ssh start", vbhide


          Solution 2 It's Task Scheduler



          Click on Start and search for Task Scheduler.



          On Task Scheduler click on Action and select Create Basic Task
          enter image description here



          On Create Basic Task Fill filed Name and Description: Auto Start SSH server



          create Basic Task



          On Trigger select: When the computer starts.



          Trigger



          On Action select Start a program



          Action



          On Start a Program type path: C:WindowsSystem32wsl.exe,
          next on add Add arguments (optional): -d Ubuntu -u root service ssh start.



          Start a Program



          You should have something like that on last step.



          finish






          share|improve this answer



























          • When I try this command I get: "/bin/bash: -d: invalid option". When I remove -d Ubuntu but keep -u root there is a similar error. With "wsl service ssh start" it runs as a non-root user and fails. "wsl sudo service ssh start" asks for a password so it cannot be autorun at startup. Perhaps after editing visudo/sudoers it could work...

            – PF92
            Oct 11 at 8:52











          • use wsl not bash if you look close all my calls was made from windows not inside Linux. correct one: C:WindowsSystem32wsl.exe -d Ubuntu -u root service ssh start

            – Cornea Valentin
            Oct 11 at 10:52











          • i forgot to mention this it's for wsl 2

            – Cornea Valentin
            Oct 11 at 10:54











          • another solutin to use bash it's to add in your /etc/sudoers this : << username >> ALL=(ALL:ALL) NOPASSWD: ALL , replace << username >> with your username then call: C:WindowsSystem32bash.exe -c "sudo service ssh start"

            – Cornea Valentin
            Oct 11 at 11:00












          • I thought WSL2 was still in beta?

            – WinEunuuchs2Unix
            Oct 11 at 15:13












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1177273%2fwsl-ubuntu-is-there-an-easy-way-to-have-bash-start-automatically-on-windows-sta%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown


























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0



















          (( update this works on WSL 2))



          Solution 1 use VBE script.



          Click on Start and search for shell:startup.
          also you can go manually to:




          C:Users<< username >>AppDataRoamingMicrosoftWindowsStart
          MenuProgramsStartup
          note: change username with your own username.




          now create a new file : sshserver.vbe and add fallow content:



          Set ws = CreateObject("Wscript.Shell") 
          ws.run "wsl -d Ubuntu -u root service ssh start", vbhide


          Solution 2 It's Task Scheduler



          Click on Start and search for Task Scheduler.



          On Task Scheduler click on Action and select Create Basic Task
          enter image description here



          On Create Basic Task Fill filed Name and Description: Auto Start SSH server



          create Basic Task



          On Trigger select: When the computer starts.



          Trigger



          On Action select Start a program



          Action



          On Start a Program type path: C:WindowsSystem32wsl.exe,
          next on add Add arguments (optional): -d Ubuntu -u root service ssh start.



          Start a Program



          You should have something like that on last step.



          finish






          share|improve this answer



























          • When I try this command I get: "/bin/bash: -d: invalid option". When I remove -d Ubuntu but keep -u root there is a similar error. With "wsl service ssh start" it runs as a non-root user and fails. "wsl sudo service ssh start" asks for a password so it cannot be autorun at startup. Perhaps after editing visudo/sudoers it could work...

            – PF92
            Oct 11 at 8:52











          • use wsl not bash if you look close all my calls was made from windows not inside Linux. correct one: C:WindowsSystem32wsl.exe -d Ubuntu -u root service ssh start

            – Cornea Valentin
            Oct 11 at 10:52











          • i forgot to mention this it's for wsl 2

            – Cornea Valentin
            Oct 11 at 10:54











          • another solutin to use bash it's to add in your /etc/sudoers this : << username >> ALL=(ALL:ALL) NOPASSWD: ALL , replace << username >> with your username then call: C:WindowsSystem32bash.exe -c "sudo service ssh start"

            – Cornea Valentin
            Oct 11 at 11:00












          • I thought WSL2 was still in beta?

            – WinEunuuchs2Unix
            Oct 11 at 15:13















          0



















          (( update this works on WSL 2))



          Solution 1 use VBE script.



          Click on Start and search for shell:startup.
          also you can go manually to:




          C:Users<< username >>AppDataRoamingMicrosoftWindowsStart
          MenuProgramsStartup
          note: change username with your own username.




          now create a new file : sshserver.vbe and add fallow content:



          Set ws = CreateObject("Wscript.Shell") 
          ws.run "wsl -d Ubuntu -u root service ssh start", vbhide


          Solution 2 It's Task Scheduler



          Click on Start and search for Task Scheduler.



          On Task Scheduler click on Action and select Create Basic Task
          enter image description here



          On Create Basic Task Fill filed Name and Description: Auto Start SSH server



          create Basic Task



          On Trigger select: When the computer starts.



          Trigger



          On Action select Start a program



          Action



          On Start a Program type path: C:WindowsSystem32wsl.exe,
          next on add Add arguments (optional): -d Ubuntu -u root service ssh start.



          Start a Program



          You should have something like that on last step.



          finish






          share|improve this answer



























          • When I try this command I get: "/bin/bash: -d: invalid option". When I remove -d Ubuntu but keep -u root there is a similar error. With "wsl service ssh start" it runs as a non-root user and fails. "wsl sudo service ssh start" asks for a password so it cannot be autorun at startup. Perhaps after editing visudo/sudoers it could work...

            – PF92
            Oct 11 at 8:52











          • use wsl not bash if you look close all my calls was made from windows not inside Linux. correct one: C:WindowsSystem32wsl.exe -d Ubuntu -u root service ssh start

            – Cornea Valentin
            Oct 11 at 10:52











          • i forgot to mention this it's for wsl 2

            – Cornea Valentin
            Oct 11 at 10:54











          • another solutin to use bash it's to add in your /etc/sudoers this : << username >> ALL=(ALL:ALL) NOPASSWD: ALL , replace << username >> with your username then call: C:WindowsSystem32bash.exe -c "sudo service ssh start"

            – Cornea Valentin
            Oct 11 at 11:00












          • I thought WSL2 was still in beta?

            – WinEunuuchs2Unix
            Oct 11 at 15:13













          0















          0











          0









          (( update this works on WSL 2))



          Solution 1 use VBE script.



          Click on Start and search for shell:startup.
          also you can go manually to:




          C:Users<< username >>AppDataRoamingMicrosoftWindowsStart
          MenuProgramsStartup
          note: change username with your own username.




          now create a new file : sshserver.vbe and add fallow content:



          Set ws = CreateObject("Wscript.Shell") 
          ws.run "wsl -d Ubuntu -u root service ssh start", vbhide


          Solution 2 It's Task Scheduler



          Click on Start and search for Task Scheduler.



          On Task Scheduler click on Action and select Create Basic Task
          enter image description here



          On Create Basic Task Fill filed Name and Description: Auto Start SSH server



          create Basic Task



          On Trigger select: When the computer starts.



          Trigger



          On Action select Start a program



          Action



          On Start a Program type path: C:WindowsSystem32wsl.exe,
          next on add Add arguments (optional): -d Ubuntu -u root service ssh start.



          Start a Program



          You should have something like that on last step.



          finish






          share|improve this answer
















          (( update this works on WSL 2))



          Solution 1 use VBE script.



          Click on Start and search for shell:startup.
          also you can go manually to:




          C:Users<< username >>AppDataRoamingMicrosoftWindowsStart
          MenuProgramsStartup
          note: change username with your own username.




          now create a new file : sshserver.vbe and add fallow content:



          Set ws = CreateObject("Wscript.Shell") 
          ws.run "wsl -d Ubuntu -u root service ssh start", vbhide


          Solution 2 It's Task Scheduler



          Click on Start and search for Task Scheduler.



          On Task Scheduler click on Action and select Create Basic Task
          enter image description here



          On Create Basic Task Fill filed Name and Description: Auto Start SSH server



          create Basic Task



          On Trigger select: When the computer starts.



          Trigger



          On Action select Start a program



          Action



          On Start a Program type path: C:WindowsSystem32wsl.exe,
          next on add Add arguments (optional): -d Ubuntu -u root service ssh start.



          Start a Program



          You should have something like that on last step.



          finish







          share|improve this answer















          share|improve this answer




          share|improve this answer








          edited Oct 11 at 10:55

























          answered Oct 5 at 14:01









          Cornea ValentinCornea Valentin

          3392 silver badges9 bronze badges




          3392 silver badges9 bronze badges















          • When I try this command I get: "/bin/bash: -d: invalid option". When I remove -d Ubuntu but keep -u root there is a similar error. With "wsl service ssh start" it runs as a non-root user and fails. "wsl sudo service ssh start" asks for a password so it cannot be autorun at startup. Perhaps after editing visudo/sudoers it could work...

            – PF92
            Oct 11 at 8:52











          • use wsl not bash if you look close all my calls was made from windows not inside Linux. correct one: C:WindowsSystem32wsl.exe -d Ubuntu -u root service ssh start

            – Cornea Valentin
            Oct 11 at 10:52











          • i forgot to mention this it's for wsl 2

            – Cornea Valentin
            Oct 11 at 10:54











          • another solutin to use bash it's to add in your /etc/sudoers this : << username >> ALL=(ALL:ALL) NOPASSWD: ALL , replace << username >> with your username then call: C:WindowsSystem32bash.exe -c "sudo service ssh start"

            – Cornea Valentin
            Oct 11 at 11:00












          • I thought WSL2 was still in beta?

            – WinEunuuchs2Unix
            Oct 11 at 15:13

















          • When I try this command I get: "/bin/bash: -d: invalid option". When I remove -d Ubuntu but keep -u root there is a similar error. With "wsl service ssh start" it runs as a non-root user and fails. "wsl sudo service ssh start" asks for a password so it cannot be autorun at startup. Perhaps after editing visudo/sudoers it could work...

            – PF92
            Oct 11 at 8:52











          • use wsl not bash if you look close all my calls was made from windows not inside Linux. correct one: C:WindowsSystem32wsl.exe -d Ubuntu -u root service ssh start

            – Cornea Valentin
            Oct 11 at 10:52











          • i forgot to mention this it's for wsl 2

            – Cornea Valentin
            Oct 11 at 10:54











          • another solutin to use bash it's to add in your /etc/sudoers this : << username >> ALL=(ALL:ALL) NOPASSWD: ALL , replace << username >> with your username then call: C:WindowsSystem32bash.exe -c "sudo service ssh start"

            – Cornea Valentin
            Oct 11 at 11:00












          • I thought WSL2 was still in beta?

            – WinEunuuchs2Unix
            Oct 11 at 15:13
















          When I try this command I get: "/bin/bash: -d: invalid option". When I remove -d Ubuntu but keep -u root there is a similar error. With "wsl service ssh start" it runs as a non-root user and fails. "wsl sudo service ssh start" asks for a password so it cannot be autorun at startup. Perhaps after editing visudo/sudoers it could work...

          – PF92
          Oct 11 at 8:52





          When I try this command I get: "/bin/bash: -d: invalid option". When I remove -d Ubuntu but keep -u root there is a similar error. With "wsl service ssh start" it runs as a non-root user and fails. "wsl sudo service ssh start" asks for a password so it cannot be autorun at startup. Perhaps after editing visudo/sudoers it could work...

          – PF92
          Oct 11 at 8:52













          use wsl not bash if you look close all my calls was made from windows not inside Linux. correct one: C:WindowsSystem32wsl.exe -d Ubuntu -u root service ssh start

          – Cornea Valentin
          Oct 11 at 10:52





          use wsl not bash if you look close all my calls was made from windows not inside Linux. correct one: C:WindowsSystem32wsl.exe -d Ubuntu -u root service ssh start

          – Cornea Valentin
          Oct 11 at 10:52













          i forgot to mention this it's for wsl 2

          – Cornea Valentin
          Oct 11 at 10:54





          i forgot to mention this it's for wsl 2

          – Cornea Valentin
          Oct 11 at 10:54













          another solutin to use bash it's to add in your /etc/sudoers this : << username >> ALL=(ALL:ALL) NOPASSWD: ALL , replace << username >> with your username then call: C:WindowsSystem32bash.exe -c "sudo service ssh start"

          – Cornea Valentin
          Oct 11 at 11:00






          another solutin to use bash it's to add in your /etc/sudoers this : << username >> ALL=(ALL:ALL) NOPASSWD: ALL , replace << username >> with your username then call: C:WindowsSystem32bash.exe -c "sudo service ssh start"

          – Cornea Valentin
          Oct 11 at 11:00














          I thought WSL2 was still in beta?

          – WinEunuuchs2Unix
          Oct 11 at 15:13





          I thought WSL2 was still in beta?

          – WinEunuuchs2Unix
          Oct 11 at 15:13


















          draft saved

          draft discarded















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1177273%2fwsl-ubuntu-is-there-an-easy-way-to-have-bash-start-automatically-on-windows-sta%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown









          Popular posts from this blog

          Distance measures on a map of a game The 2019 Stack Overflow Developer Survey Results Are Inmin distance in a graphShortest distance path on contour plotHow to plot a tilted map?Finding points outside of a diskDelaunay link distanceAnnulus from GeoDisks: drawing a ring on a mapNegative Correlation DistanceFind distance along a path (GPS coordinates)Finding position at given distance in a GeoPathMathematics behind distance estimation using camera

          How to get a smooth, uniform ParametricPlot of a 2D Region?How to plot a complicated Region?How to exclude a region from ParametricPlotHow discretize a region placing vertices on a specific non-uniform gridHow to transform a Plot or a ParametricPlot into a RegionHow can I get a smooth plot of a bounded region?Smooth ParametricPlot3D with RegionFunction?Smooth border of a region ParametricPlotSmooth region boundarySmooth region plot from list of pointsGet minimum y of a certain x in a region

          Genealogie vun de Merowenger Vum Merowech bis zum Chilperich I. | Navigatiounsmenü