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;
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
add a comment
|
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
add a comment
|
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
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
windows-subsystem-for-linux
asked Sep 28 at 12:16
PF92PF92
32 bronze badges
32 bronze badges
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
(( 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
On Create Basic Task Fill filed Name and Description: Auto Start SSH server

On Trigger select: When the computer starts.

On Action select Start a program

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

You should have something like that on last step.

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
|
show 2 more comments
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
(( 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
On Create Basic Task Fill filed Name and Description: Auto Start SSH server

On Trigger select: When the computer starts.

On Action select Start a program

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

You should have something like that on last step.

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
|
show 2 more comments
(( 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
On Create Basic Task Fill filed Name and Description: Auto Start SSH server

On Trigger select: When the computer starts.

On Action select Start a program

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

You should have something like that on last step.

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
|
show 2 more comments
(( 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
On Create Basic Task Fill filed Name and Description: Auto Start SSH server

On Trigger select: When the computer starts.

On Action select Start a program

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

You should have something like that on last step.

(( 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
On Create Basic Task Fill filed Name and Description: Auto Start SSH server

On Trigger select: When the computer starts.

On Action select Start a program

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

You should have something like that on last step.

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
|
show 2 more comments
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
|
show 2 more comments
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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