Skip to content

Commit c9fdb89

Browse files
authored
Update README.md
1 parent 2449f80 commit c9fdb89

File tree

1 file changed

+36
-17
lines changed

1 file changed

+36
-17
lines changed

README.md

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,53 +108,64 @@ Despite following the steps above, you might encounter some issues. Here are som
108108
**Symptom:** SSH connection attempt results in a timeout.
109109

110110
**Possible causes and solutions:**
111-
- WSL SSH service is not running.
112-
- Solution: In WSL, run `sudo service ssh start`
113-
- Port forwarding is not set up correctly.
114-
- Solution: Check with `netsh interface portproxy show v4tov4`
111+
- WSL SSH service is not running.
112+
113+
**Solution**: In WSL, run `sudo service ssh start`
114+
- Port forwarding is not set up correctly.
115+
116+
**Solution**: Check with `netsh interface portproxy show v4tov4`
115117
- If empty, set up port forwarding as described in Step 2
116-
- Windows Firewall is blocking the connection.
117-
- Solution: Verify the firewall rule for port 2222 is active
118+
- Windows Firewall is blocking the connection.
119+
120+
**Solution**: Verify the firewall rule for port 2222 is active
118121

119122
### 2. Authentication Failure
120123

121124
**Symptom:** Connection establishes, but you get a "Permission denied (publickey)" error.
122125

123126
**Possible causes and solutions:**
124127
- The public key is not properly added to `authorized_keys`.
125-
- Solution 1: Verify the content of `~/.ssh/authorized_keys` in WSL
126-
- Solution 2: use `ssh-copy-id` to update `~/.ssh/authorized_keys` on linux:
128+
129+
**Solution 1**: Verify the content of `~/.ssh/authorized_keys` in WSL
130+
131+
**Solution 2**: use `ssh-copy-id` to update `~/.ssh/authorized_keys` on linux:
127132
1. Enable password login from Linux by updating `/etc/ssh/sshd_config`, set `PasswordAuthentication` to `yes`
128133
2. Run `ssh-copy-id` from your mac
129134
``` bash
130135
ssh-copy-id -i ~/.ssh/id_rsa -n -p 2222 <your user name>@<your windows machine name or ip address>
131136
```
132137
- Incorrect permissions on SSH files.
133-
- Solution: In WSL, run:
138+
139+
**Solution**: In WSL, run:
134140
```bash
135141
chmod 700 ~/.ssh
136142
chmod 600 ~/.ssh/authorized_keys
137143
```
138144
- Incorrect filename for authorized keys.
139-
- Solution: Ensure the file is named `authorized_keys`, not `authorized_users` or anything else
145+
146+
**Solution**: Ensure the file is named `authorized_keys`, not `authorized_users` or anything else
140147

141148
### 3. SSH Server Refuses Connection
142149

143150
**Symptom:** You get a "Connection refused" error.
144151

145152
**Possible causes and solutions:**
146153
- SSH server is not running on the specified port.
147-
- Solution: Check SSH config in WSL (`/etc/ssh/sshd_config`) to ensure it's set to use port 2222
154+
155+
**Solution**: Check SSH config in WSL (`/etc/ssh/sshd_config`) to ensure it's set to use port 2222
156+
148157
- WSL instance is not running.
149-
- Solution: Open a WSL terminal on your Windows machine to start the instance
158+
159+
**Solution**: Open a WSL terminal on your Windows machine to start the instance
150160
151161
### 4. Host Key Verification Failed
152162
153163
**Symptom:** You get a "Host key verification failed" error.
154164
155165
**Possible causes and solutions:**
156166
- The host key has changed (common if you've reinstalled WSL).
157-
- Solution: Remove the old key from your Mac's `known_hosts` file:
167+
168+
**Solution**: Remove the old key from your Mac's `known_hosts` file:
158169
```bash
159170
ssh-keygen -R "[your_windows_ip]:2222"
160171
```
@@ -165,7 +176,8 @@ Despite following the steps above, you might encounter some issues. Here are som
165176
166177
**Possible causes and solutions:**
167178
- WSL IP address has changed after a restart.
168-
- Solution: Update the port forwarding rule with the new IP:
179+
180+
**Solution**: Update the port forwarding rule with the new IP:
169181
1. In WSL, get the new IP: `ip addr show eth0`
170182
2. In Windows PowerShell (as admin), update the rule:
171183
```powershell
@@ -179,16 +191,23 @@ Despite following the steps above, you might encounter some issues. Here are som
179191
180192
**Possible causes and solutions:**
181193
- Windows OpenSSH is not using the WSL shell.
182-
- Solution: Set the default shell for SSH connections:
194+
195+
**Solution**: Set the default shell for SSH connections:
183196
1. In Windows PowerShell (as admin):
184197
```powershell
185198
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\wsl.exe" -PropertyType String -Force
186199
```
187200
2. Restart the SSH service: `Restart-Service sshd`
188201
189-
Remember, when troubleshooting SSH connections, the verbose mode (`ssh -v wsl`) can provide helpful diagnostic information. Don't hesitate to use it when you encounter issues.
202+
Remember, when troubleshooting SSH connections, the verbose mode (`ssh -v wsl`) can provide helpful diagnostic information.
190203
191-
By being aware of these common issues and their solutions, you'll be better prepared to troubleshoot any problems that arise when setting up SSH access to your WSL environment from your Mac.
204+
### 7. Connection Closed by Remote Host
205+
206+
**Symptom:** You get an error message like "Connection closed by [your_ip_address] port 2222".
207+
**Possible causes and solutions:**
208+
- **Stale SSH known_hosts entries**: Your Mac might have old or incorrect SSH key information for the WSL instance.
209+
210+
**Solution**: Delete the ~/.ssh/known_hosts file or the specific outdated entry within that file on your Mac. You might also have a ~/.ssh/known_hosts.old file that could be causing issues if it was recently renamed. Try removing or renaming this file as well. The next time you connect, you will be prompted to accept the new host key.
192211
193212
## Contributing
194213

0 commit comments

Comments
 (0)