Skip to content

Instantly share code, notes, and snippets.

@RHDZMOTA
Last active April 14, 2024 19:58
Show Gist options
  • Save RHDZMOTA/2418318a6f786e8a09ab6a69009ccf5a to your computer and use it in GitHub Desktop.
Save RHDZMOTA/2418318a6f786e8a09ab6a69009ccf5a to your computer and use it in GitHub Desktop.
SSH into the Windows Subsystem for Linux (ubuntu)

SSH Into the Windows Subsystem for Linux (UBUNTU)

Instructions to create an ssh connection into the windows subsystem for linux.

Context

Instructions

Follow these steps in order to enable ssh-connections into your Linux Subsystem:

  1. Enter you Linux App.
  2. Uninstall the SSH Server: sudo apt-get purge openssh-server
  3. Reinstall the SSH Server: sudo apt-get install openssh-server
  4. Edit the ssh-config file:
  • Disable root login: PermitRootLogin no
  • Grant access to your user: AllowUsers <your-user-name>
  • Enable password authentication: PasswordAuthentication yes
  • Disable privilege separation UsePrivilegeSeparation no
  • Change default port: Port 2222
  1. Reestart the SSH Service: sudo service ssh --full-restart

Now you can connect via ssh (using PuTTY or git-bash in Windows). Example:

  1. Open git-bash terminal
  2. Connect via ssh: ssh -p 2222 <your-user-name>@<your-ip-address>
  3. Or connect via sftp: sftp -P 2222 <your-user-name>@<your-ip-address>

To find out your ip run:

  • In Linux run ifconfig and see the inet value unser the wifi block.
  • In Windows run ipconfig and look for the IPvX Address in the Wifi-Adapter block.
@peterpolgar
Copy link

Where do I find the ssh config file?

/etc/ssh/sshd_config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment