Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Push button doesn't work #1423

@isaacschneuder

Description

@isaacschneuder

Hi, this is a solution for users who had the same issue as me.
Today I tried to connect my repository from JupyterLab to my GitHub and I had some troubles with it.
I used jupyter-git for several days and it seemed to work fine (for example, commit worked as it should), but then I decided to connect to my GitHub. I generated SSH keys from the docs:

https://docs.github.com/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent?platform=linux

Then I ran ssh -vT [email protected] and I successfully authenticated. After that, I was able to push commits from the terminal. But when I opened another terminal window and tried to push, or tried to do "Git -> Push to remote" in JupyterLab, I got the message:

[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."

I didn't find any solution on the Internet that could work for me, so, this is the solution that worked for me.


Step 1:

In the jupyterlab terminal:

ssh -T [email protected] -v
ssh-add -l
env | grep -E '^SSH_'
git remote -v

If ssh-add -l shows “The agent has no identities” or if env is empty for SSH_ — this is our case.

Step 2:

Add these lines to the end of ~/.bashrc:

if [ -z "$SSH_AUTH_SOCK" ]; then
    eval "$(ssh-agent -s)" >/dev/null
    ssh-add ~/.ssh/id_ed25519 2>/dev/null
fi

Now, every time you open a terminal (and when starting JupyterLab), the agent will launch and load the key automatically.

Step 3:

# Add the key to the persistent agent
ssh-add ~/.ssh/id_ed25519

# Check
ssh-add -l
ssh -T [email protected]

Step 4 (if required):

Open/create ~/.ssh/config and paste:

Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519
  IdentitiesOnly yes

Close the file.
Enter the following commands in terminal:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
ssh-keyscan github.com >> ~/.ssh/known_hosts

Restart the JupyterLab server.


I'm newbie, but hope this helps you if you are facing the same problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions