tldr
I have tried many approaches troubleshooting npm run deploy to deploy using SSH on GitHub Pages and it gives the error:
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Thankfully, I have implemented a solution with a manual work around: https://stackoverflow.com/questions/75075815/gh-pages-permission-denied/78201454#78201454
Also, npm run deploy does work if I use HTTPS instead of SSH by running the following command:
git remote set-url origin https://github.com/my-github-username/repository.git
followed by:
npm run deploy
However, npm run deploy does not work with SSH.
Here are the steps I have taken to troubleshoot:
- Checked my SSH key configuration on my local machine. I have verivied by running:
ssh -T [email protected]
and it outputs
Hi my-github-username. You've successfully authenticated, but GitHub does not provide shell access.
- Verify access to the repo that I am deploying to with the command:
git remote -v
- Made sure the deployment script in my package.json is correct. Here is my package.json file:
{
"homepage": "https://my-github-username.github.io/repo-name/",
"name": "react-portfolio",
"version": "0.1.0",
"private": true,
"dependencies": {
"@primer/octicons-react": "^17.12.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.3.3",
"bootstrap": "^3.4.1",
"cors": "^2.8.5",
"emailjs-com": "^3.2.0",
"jquery": "^3.6.3",
"nodemailer": "^6.9.1",
"now-ui-kit": "^1.3.0",
"react": "^17.0.2",
"react-bootstrap": "^2.7.2",
"react-dom": "^17.0.2",
"react-router-dom": "^6.11.2",
"react-scripts": "^2.1.3",
"react-social-icons": "^5.15.0",
"reactstrap": "^9.2.0",
"web-vitals": "^2.1.4"
},
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"gh-pages": "^5.0.0",
"sass": "^1.58.3"
}
}
Checked the GitHub pages settings to make sure that I am deploying to the correct branch.
Ensured that the access tokens are correctly set up with the permissions needed.
Please, I am curious as to why SSH just does not work.