-
-
Save HCY-ASLEEP/dd9f85128f60d0d17407f3c4351947b3 to your computer and use it in GitHub Desktop.
Enable sshd on MinGW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Configure sshd on MinGW for Windows | |
# Create host keys | |
ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa | |
ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa | |
ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -N '' -t ecdsa | |
ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -N '' -t ed25519 | |
# Configure sshd for password authentication with no user privilege authentication | |
sed -i '/UsePrivilegeSeparation /c\UsePrivilegeSeparation no' /etc/ssh/sshd_config | |
sed -i '/PasswordAuthentication /c\PasswordAuthentication yes' /etc/ssh/sshd_config | |
/usr/bin/sshd && echo "sshd is running" || { echo 1>&2 "Can't execute sshd, exiting without configuring windows"; exit 1; } | |
# Schedule sshd to start on boot and creates firewall rule for it on port 22 | |
schtasks //CREATE //SC onstart //TN "mingw-sshd" //TR $(CYGPATH -w `which sshd`) //F | |
netsh advfirewall firewall delete rule name="mingw-sshd" | |
netsh advfirewall firewall add rule name="mingw-sshd" protocol=tcp localport=22 dir=in enable=yes action=allow | |
echo "sshd was configured properly to start on boot" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment