I'm trying to get headless SSH access to a Pi Zero 2 W using a USB cable from my Mac... However the SSH is failing with "Permission denied, please try again.". What am I doing wrong?
These are the steps I'm following:
- Flash Raspberry Pi OS Lite 64-bit version (released 2022-04-04) using Pi Imager to SD card
- In
config.txt
, add this as the last line of the file:dtoverlay=dwc2
- In
cmdline.txt
, add this as a parameter, just after therootwait
parameter:modules-load=dwc2,g_ether
- Add empty file called
ssh
- Connect Pi to Mac with USB cable, making sure to connect to USB port on Pi (not PWR)
- Boot Pi
- Check in Mac
System Preferences > Sharing
thatInternet Sharing
andRNDIS/Ethernet Gadget
are ticked. - Ping Pi:
ping raspberrypi.local
, check that it has a192.168.X.Y
address. - Pull the power out while it's pinging, check that it stops (proving that this is definitely our Pi and not another on the network!)
- Boot Pi again
- Try to SSH to Pi, using password
raspberry
:
osx~ $ ssh -v [email protected]
OpenSSH_8.6p1, LibreSSL 2.8.3
debug1: Reading configuration data /Users/dave/.ssh/config
debug1: /Users/dave/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to raspberrypi.local port 22.
debug1: Connection established.
debug1: identity file /Users/dave/.ssh/id_rsa type 0
debug1: identity file /Users/dave/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.4p1 Debian-5
debug1: compat_banner: match: OpenSSH_8.4p1 Debian-5 pat OpenSSH* compat 0x04000000
debug1: Authenticating to raspberrypi.local:22 as 'pi'
debug1: load_hostkeys: fopen /Users/dave/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:Qs/dlJ7rsKrqH5v0XpxSZhcx1PVA1fGLJ1Fgn7hv86o
debug1: load_hostkeys: fopen /Users/dave/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: hostkeys_find_by_key_hostfile: hostkeys file /Users/dave/.ssh/known_hosts2 does not exist
debug1: hostkeys_find_by_key_hostfile: hostkeys file /etc/ssh/ssh_known_hosts does not exist
debug1: hostkeys_find_by_key_hostfile: hostkeys file /etc/ssh/ssh_known_hosts2 does not exist
The authenticity of host 'raspberrypi.local (192.168.2.4)' can't be established.
ED25519 key fingerprint is SHA256:Qs/dlJ7rsKrqH5v0XpxSZhcx1PVA1fGLJ1Fgn7hv86o.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'raspberrypi.local' (ED25519) to the list of known hosts.
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /Users/dave/.ssh/id_rsa RSA SHA256:I7UgZAer3VjGf73X801UKYiTB9XRdXesCmls9ev33Kc explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected]>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/dave/.ssh/id_rsa RSA SHA256:I7UgZAer3VjGf73X801UKYiTB9XRdXesCmls9ev33Kc explicit
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password
[email protected]'s password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
[email protected]'s password: