I used git in Linux but right now I have to use Windows OS. The problem is that I can not clone files.
I generate a ssh key by using the ssh-keygen -o -t rsa -b 4096 command and copied the key (the long text and added the text in the ssh key file to my git SSH-key in setting.
Then try the command :
git clone Clone with SSH
I exits with this error:
git#gitlab.liu.se: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Related
I have a project with a submodule configured. It uses a relative path, so it should be checked out via ssh (because I cloned the parent project with ssh).
I did:
git submodule update --init --recursive --remote
and the error is on Windows Powershell: Permission denied
I think I also found the reason for this. My ssh key is protected with a password. So powershell should ask me for the password as it does when using git clone. But apparently it does not.
So I got a few workarounds:
Use git bash on Windows (asks me for the passsword and thus works perfectly)
Don't use a password for ssh
Don't use ssh
All workarounds are not ideal. So I wonder: Is this a known issue / limitation? Can I do anything about this?
If those submodules are using an SSH URL (check your .gitmodules), then you can try and use an ssh-agent in your Powershell session.
Test it with ssh -Tv remoteUser#remoteServer (for GitHub remote repositories, that would be ssh -Tv git#github.com)
The first query should ask for your SSH passphrase, but after that, you should be able to clone/submodule update without any more prompt.
I try to clone a repo from a brand new Windows Install with wsl (Ubuntu 20.04).
What I did : generate SSH key and add public key to both github and framagit.
Tried
ssh -i -T git#github.com
And
ssh -i -T git#framagit.org
Both of them saied "Hello my pseudo, you're authentified"
But when I try to clone I have the following :
Without sudo :
Cloning into 'testaaa'...
error: chmod on /mnt/d/dev/dev/testaaa/.git/config.lock failed: Operation not permitted
fatal: could not set 'core.filemode' to 'false'
With sudo :
Cloning into 'testaaa'...
ssh: connect to host framagit.org port 22: Network is unreachable
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
What can I do to solve my issue?
You can fix this by following this guide. Summary below.
From a WSL prompt:
sudo vim /etc/wsl.conf
Add these lines:
[automount]
options = "metadata"
Save the file, shutdown wsl from a PowerShell prompt:
wsl --shutdown
Re-open a wsl terminal. You should see files owned by your user now instead of root. You can now git clone, chmod, chown etc.
You don't want to use sudo here, and in general there's no reason to need it with Git unless the repository you're working with is owned specifically by root.
The problem you're seeing is that you're using a Linux Git, which expects standard Unix permissions to work, on a file system (NTFS) that does not support them. Git will try to set the permissions appropriately when it rewrites the lock file which it will rename into places as the config file, but it can't do so, and it fails. Git for Windows doesn't have this problem because it maps these permissions differently from WSL, which just always returns an error.
You can try a couple of things:
Just clone the repository under WSL and not under a Windows drive. This is guaranteed to work, and should be fine.
Clone the repository somewhere under WSL and move it into a Windows drive, either setting the config options manually for Windows or trying git init again in the repository after cloning.
Run git init on the Windows drive and then do a git remote add origin YOUR-REMOTE and a git pull origin master (or whatever your branch is called).
It's possible that the last one may not work any better than what you have now, since git init may fail the same way.
I'm using Windows Git-bash to push to my repository using ssh (not https). I have followed the instructions in this page
https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
$ ssh-keygen -t rsa -b 4096 -C "barghouti_since88#hotmail.com"
$ ssh-add ~/.ssh/id_rsa
Then copied the key in ~/.ssh/id_rsa and copied it to my ssh keys in github account by following this setup
https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
But now when I try to push using
$git add file
$git commit -m "adding file"
$git push
I'm getting the following
FATAL ERROR: Couldn't agree a key exchange algorithm (available: curve25519-sha256,curve25519-sha256#libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521)
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
There are a few possibilities you can examine:
did you "git clone" the repository with 'https' instead of 'git'? If
you want to git push with ssh, you need to clone with ssh as well.
is your Git for Windows version recent enough ? every once in a while, GitHub removes support for older, weaker, crypto, and your
software needs to match the server's algorithms, which in this case
it didn't, per the error message.
are you using the same ssh software as git ? Git for Windows comes with ssh included, but ssh can also have been installed separately,
on its own as OpenSSH, or included with putty, for instance. Compare
the output of 'where ssh-keygen' with the environment variable
GIT_SSH.
Hope this helps
When doing a git pull on a project with GIT tags, I get the error below.
I use msysgit on Win8, versions:
git-gui version 0.19.GITGUI
git version 1.9.5.msysgit.1
Tcl/Tk version 8.5.13
The error I get is:
$ git pull --tags
Enter passphrase for key '/c/Users/Me/.ssh/id_rsa':
fatal: Unable to create 'c:/Users/Me/someproject/.git/refs/remotes/origin/lpt1.2-support.lock': No such file or directory
fatal: The remote end hung up unexpectedly
Any clues?
I think the ssh couldn't find your keys. Make sure they are in the default location.
Try to clone the remote. If you are not able to clone and you get the message "The remote end hung up unexpectedly". We can suspect that the your ssh key is not in the default location.
If you are able to clone, and couldn't pull check if you have any locks and the directory exist on your local. c:/Users/Me/someproject/.git/refs/remotes/origin/lpt1.2-support.lock
On msysgit, check if the variable HOME is set. HOME can be set to any directory you want, you only have to make sure you have the right to write in it (and that the directory exists and a .ssh under it exists too).
ssh-keygen -t rsa
And follow the prompts there.
If the problem is solved could you please let me know which of the three cases above helped you.
In windows when I try git pull origin master, I get this error. But it works when I try from Git Bash.
Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists
.
This error comes when I try from windows command prompt.
My assumption is that when run outside of Git Bash, git can't find your private key for the repository you are trying to access.
Run echo $HOME in Git Bash and set HOME in Windows command prompt and compare results.