You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派部署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 dietpi in the connected devices list.
    • On a Linux machine, scan your local network with arp-scan -l to find the Raspberry Pi's MAC address (typically starts with B8:27:EB or DC:A6:32) and its corresponding IP. On Windows, use arp -a in 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 -L or ufw status to 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_config on 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 route to check the routing table.
  • Ensure IP forwarding is enabled on the gateway:
    cat /proc/sys/net/ipv4/ip_forward
    
    If the output is 0, enable it temporarily with:
    echo 1 > /proc/sys/net/ipv4/ip_forward
    
    To make it permanent, edit /etc/sysctl.conf and set net.ipv4.ip_forward=1, then run sysctl -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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:12:21