Skip to content

Pass github token

Pass github token #43

Workflow file for this run

name: WSL Test
on: [push, workflow_dispatch]
jobs:
wsl:
runs-on: windows-2019
defaults:
run:
shell: wsl-bash {0}
steps:
- uses: actions/checkout@v2
- uses: Vampire/setup-wsl@v1
with:
distribution: Ubuntu-20.04
set-as-default: 'true'
wsl-shell-user: wsl
- name: List WSL distributions
shell: cmd
run: wslconfig /list
- name: Show WSL environment
run: |
mount
- name: Change mount options and restart
shell: powershell
run: |
wsl -u root bash -c "printf '[automount]\nenabled = true\noptions = `"metadata,uid=1000,gid=1000,umask=22,fmask=11`"\n' | tee /etc/wsl.conf"
wslconfig /terminate Ubuntu-20.04
- name: Show WSL environment again
run: |
mount
- name: Run command by default user
run: |
umask
whoami
id
env
ls -alh .
ls -alh ~
- name: Run command by root user
shell: wsl-bash -u root {0}
run: |
umask
whoami
id
env
ls -alh .
ls -alh ~
- name: Run command by wsl user
shell: wsl-bash -u wsl {0}
run: |
umask
whoami
id
env
ls -alh .
ls -alh ~
connect-by-ssh:
runs-on: windows-2019
defaults:
run:
shell: wsl-bash {0}
steps:
- uses: actions/checkout@v2
- uses: Vampire/setup-wsl@v1
with:
distribution: Ubuntu-20.04
set-as-default: 'true'
wsl-shell-user: wsl
- name: Generate a ssh key pair in WSL
run: |
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -N ""
- name: Setup Windows SSH Server
shell: powershell
run: |
# Install SSH Server
choco install -y openssh --params "/SSHServerFeature"
# Register a authorized key
(wsl.exe -- cat /home/wsl/.ssh/id_rsa.pub) -join "`n" `
| % { [Text.Encoding]::UTF8.GetBytes($_) } `
| Set-Content -Path 'C:\ProgramData\ssh\administrators_authorized_keys' -Encoding Byte
# Repair permissions for authorized key file
icacls 'C:\ProgramData\ssh\administrators_authorized_keys' /inheritance:d
icacls 'C:\ProgramData\ssh\administrators_authorized_keys' /remove 'NT AUTHORITY\Authenticated Users'
icacls 'C:\ProgramData\ssh\administrators_authorized_keys'
Restart-Service -Name sshd -Force
- name: Connect to ssh server
run: >-
ssh runneradmin@localhost -vvv -o StrictHostKeyChecking=no
-o UserKnownHostsFile=/dev/null -o PreferredAuthentications=publickey
-o PasswordAuthentication=no
-- dir