树莓派部署DietPi后SSH访问被拒绝问题求助
Troubleshooting SSH Connection Issues with DietPi on Raspberry Pi
Hey there! Let's work through this SSH problem step by step—these are the most common checks and fixes to get you connected:
1. Verify DietPi's Network & IP Address
- First, confirm your DietPi device is actually connected to the network:
- Hook up a monitor to your Raspberry Pi; the initial boot screen should display the assigned IP address.
- Alternatively, log into your router's admin panel and look for a device named
dietpiin the connected devices list. - On a Linux machine, scan your local network with
arp-scan -lto find the Raspberry Pi's MAC address (typically starts withB8:27:EBorDC:A6:32) and its corresponding IP. On Windows, usearp -ain Command Prompt.
2. Ensure SSH Service is Running on DietPi
DietPi enables SSH by default, but it never hurts to confirm:
- If you have a monitor attached, log in with the default credentials (
root/dietpi) and run:systemctl status sshd - If the service isn't active, start it with:
systemctl start sshd - To make it start automatically on boot:
systemctl enable sshd - Also, check if you completed the initial DietPi setup wizard—sometimes SSH isn't fully available until you walk through the first-time configuration (timezone, user setup, etc.).
3. Check Firewall Settings
- On DietPi: By default, the firewall is disabled, but verify with
ufw status. If it's active, allow SSH traffic:ufw allow ssh - On Windows Client: Check Windows Defender Firewall to ensure it's not blocking outbound connections on port 22.
- On Linux Gateway: Confirm the gateway's firewall allows SSH traffic between your Windows client and DietPi. Use
iptables -Lorufw statusto review rules, and add an allow rule if needed.
4. Validate SSH Client Configuration
- Double-check the IP address you're entering in PuTTY/Bitvise—make sure it's the DietPi device's IP, not your gateway or another device.
- Confirm the port is set to
22(DietPi's default). If you changed it during setup, check the value in/etc/ssh/sshd_configon DietPi. - In PuTTY, ensure you've selected SSH as the connection type (not Telnet or Raw).
5. Confirm Credentials Are Correct
- Even though you're using the default
root/dietpi, double-check for typos (Caps Lock is a common culprit!). Remember, PuTTY doesn't display characters when entering the password. - If you suspect the password was changed during setup, log in via monitor and reset it with:
passwd root
6. Troubleshoot the Linux Gateway Setup
Since you're using a Linux server as a gateway, rule out routing issues:
- Verify the gateway has proper routes to forward traffic between your Windows client's network and DietPi's network. Run
ip routeto check the routing table. - Ensure IP forwarding is enabled on the gateway:
If the output iscat /proc/sys/net/ipv4/ip_forward0, enable it temporarily with:
To make it permanent, editecho 1 > /proc/sys/net/ipv4/ip_forward/etc/sysctl.confand setnet.ipv4.ip_forward=1, then runsysctl -p. - Test connecting directly without the gateway (connect Windows and DietPi to the same local network) to isolate if the gateway is the bottleneck.
内容的提问来源于stack exchange,提问作者Victor
相关产品推荐
相关产品推荐

