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

树莓派通过以太网SSH连接Ubuntu时权限拒绝的求助

解决树莓派SSH连接Ubuntu时的Permission Denied问题

Hey there, let's troubleshoot this SSH permission denied issue together—this is a pretty common snag, but we'll get your Pi connected to Ubuntu in no time. Let's go through the most likely fixes step by step:

1. Double-check the basics first

  • Make sure you're using the correct Ethernet IP address for your Raspberry Pi. On the Pi itself (connect a monitor or use serial access), run hostname -I to get its wired IP—don't accidentally use the WiFi IP if both are enabled.
  • Confirm the Pi's username is actually pi. Some newer Raspberry Pi OS builds let you set a custom username during setup, so if you changed it, replace pi with your actual username in the SSH command.

2. Verify SSH is enabled and configured correctly on the Pi

  • First, check if the SSH service is running on the Pi:
    sudo systemctl status ssh
    
    If it shows active (running), great. If not, enable and start it with:
    sudo systemctl enable --now ssh
    
  • Next, make sure password authentication is allowed in the SSH config:
    Edit the config file with sudo nano /etc/ssh/sshd_config, then find these lines:
    PasswordAuthentication yes
    ChallengeResponseAuthentication no
    
    Ensure PasswordAuthentication is set to yes (remove the # if it's commented out). Save the file (Ctrl+O, then Enter) and exit nano (Ctrl+X), then restart SSH to apply changes:
    sudo systemctl restart ssh
    

3. Don't overlook password typos!

  • Raspberry Pi passwords are case-sensitive, and when you type them into SSH, you won't see any characters (no asterisks, nothing)—this is normal. Double-check you're entering the exact password, then hit Enter.
  • If you're unsure, log into the Pi locally first to confirm the password works.

4. Check Ubuntu's firewall settings

  • Ubuntu's default UFW firewall might be blocking incoming SSH connections. Try temporarily disabling it to test:
    sudo ufw disable
    
    If you can connect now, add a rule to allow SSH permanently, then re-enable the firewall:
    sudo ufw allow ssh
    sudo ufw enable
    

5. Bypass public key authentication (if it's interfering)

  • The error mentions publickey, which means your Ubuntu system might be trying to use SSH keys instead of a password, but the Pi doesn't have your public key stored. Force password-only authentication with this command:
    sudo ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no pi@<your-pi-ip>
    
    This skips public key attempts and only uses password login.

6. Reset SSH on the Pi (last resort)

  • If nothing else works, completely reinstall the SSH server on the Pi to reset to default settings:
    sudo apt-get purge openssh-server
    sudo apt-get install openssh-server
    sudo systemctl enable --now ssh
    
    Then try connecting again.

内容的提问来源于stack exchange,提问作者user7910594

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 08:34:56