树莓派通过以太网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 -Ito 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, replacepiwith 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:
If it showssudo systemctl status sshactive (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 withsudo nano /etc/ssh/sshd_config, then find these lines:
EnsurePasswordAuthentication yes ChallengeResponseAuthentication noPasswordAuthenticationis set toyes(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:
If you can connect now, add a rule to allow SSH permanently, then re-enable the firewall:sudo ufw disablesudo 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:
This skips public key attempts and only uses password login.sudo ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no pi@<your-pi-ip>
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:
Then try connecting again.sudo apt-get purge openssh-server sudo apt-get install openssh-server sudo systemctl enable --now ssh
内容的提问来源于stack exchange,提问作者user7910594
相关产品推荐
相关产品推荐

