"Permission denied (public key)" error from Laravel Forge after copying ssh key using xclip or pbcopy

I use Laravel Forge to run several Laravel projects. It has an interface to add SSH keys to a server so that you can SSH into them, but I’ve repeatedly hit a little issue when trying to use xclip on Linux or pbcopy on Mac to copy the public key and paste it into the Forge interface.

Somehow the public key is not copied properly and you’ll get the generic Permission denied (public key) error when trying to SSH into the server.

I’ve found that the workaround is as simple as using a text editor like Sublime to copy the SSH key instead of the commandline utilities. I don’t know why this avoids the issue, but it does!


Tech mentioned