Skip to content

Instantly share code, notes, and snippets.

@mastdiekin
Forked from jaimehrubiks/ssh_wsl.txt
Created February 27, 2021 16:13
Show Gist options
  • Save mastdiekin/a43538bf3f09e9875a82ce6ed1969a89 to your computer and use it in GitHub Desktop.
Save mastdiekin/a43538bf3f09e9875a82ce6ed1969a89 to your computer and use it in GitHub Desktop.
Make SSH work in WSL [Windows subsystem for Linux] (Tested in Ubuntu Oct 2018)
# 1. Reinstall open ssh server
sudo apt-get purge openssh-server
sudo apt-get install openssh-server
# 2. Install public key
# vim .ssh/authorized_keys blabla
chmod 400 .ssh/authorized_keys
# 3. Edit open ssh server config files
# Some settings are not needed, but these will help for sure to make it work
vim /etc/ssh/sshd_config
---------------------------
AllowUsers yourusername
UsePrivilegeSeparation no
Port 2222
PubkeyAuthentication yes
ListenAddress 0.0.0.0
PubkeyAuthentication yes
PasswordAuthentication no
PermitEmptyPasswords no
---------------------------
# 4. Restart service fully
sudo service ssh --full-restart
# 5. Connect from remote machine
ssh yourusername@ip -p 2222 -i .ssh/id_rsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment