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.
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'm trying to clone a repository the ssh way from github and another form gitlab
I'm on windows EDIT : with Git v 2.29.2.2
I'm getting the following error, which I do not understand from what it is coming from :
$ git clone git#github.com:math-gallou/AI21_TPs.git
Cloning into 'AI21_TPs'...
git: 'git#github.com' is not a git command. See 'git --help'.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
So I also tried :
$ git clone "ssh://git#github.com:math-gallou/AI21_TPs.git"
and
$ git clone ssh://git#github.com:math-gallou/AI21_TPs.git
But the same exact error comes out.
When I do the ssh -v git#github.com I can connect with success.
So what did I miss ?
First, if you are trying the ssh:// syntax, then the URL would be:
git clone ssh://git#github.com/math-gallou/AI21_TPs.git
^^^ /, not :
Second, check if you have a %USERPROFILE%\.ssh\config file with a github.com Host entry in it, whose content might be incorrect or mis-interpreted.
In my case, I defined system environment variable GIT_SSH to use openssh I installed, and then git is broken and I got git: 'git#github.com' is not a git command. See 'git --help'..
After deleting system environment variable GIT_SSH everything works again.
Then I tried to define user environment variable GIT_SSH and restart system (I didn't restart system in previous try), somehow now my git works correctly with openssh I installed. I don't know which part is wrong in my previous try but I decide not to waste more time on this.
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
I have installed gitolite on windows server using cygwin, installation steps went without problems and when I try to "ssh gitadmin#gitserver info" from local machine(windows) I get the correct response:
hello gitoliteAdmin, this is gitadmin#VRGWLSDEV1T running gitolite3 v3.6.1-6-gdc
8b590 on git 1.9.4.msysgit.0
R W gitolite-admin
R W testing
If I try to clone using Git Bash I get error:
$ git clone gitadmin#gitserver:gitolite-admin
Cloning into 'gitolite-admin'...
git: 'shell' is not a git command. See 'git --help'.
Did you mean this?
help
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
If I try to clone using cygwin terminal on local mashine (using the same ssh key and I get the same valid gitolite message) it returns:
$ git clone gitadmin#gitserver:gitolite-admin.git
Cloning into 'gitolite-admin'...
...and stays like that for enternity!
I have searched for multiple solutions, added PATH (with Git etc.) to .bashrc and .bash_profile files on gitolite designated server. Also added PATH to .gitolite.rc to include custom Git installation path (before that I did not recieve the gitolite message)
If you have any solution or idea what did I do wrong: please....HELP.
Resolved it by myself:
Mysis Git installation was confusing Cygwin. Added Git pack to Cygwin and removed Msys Git env. variables: everything woks perfectly now.
I am trying to clone a remote repository on Windows, but when I did this:
git clone git#github.com:organization/xxx.git
I got this error:
error: cannot run ssh: No such file or directory
fatal: unable to fork
Am I missing something?
Check if you have installed ssh-client. This solves the problem on docker machines, even when ssh keys are present:
apt-get install openssh-client
You don't have ssh installed (or don't have it within your search path).
You can clone from github via http, too:
git clone http://github.com/organization/xxx
Most likely your GIT_SSH_COMMAND is referencing the incorrect public key.
Try:
export GIT_SSH_COMMAND="ssh -i /home/murphyslaw/.ssh/your-key.id_rsa
then
git clone git#github.com:organization/xxx.git
I am aware that it is an old topic, but having this problem recently, I want to bring here what I resolve my issue.
You might have this error on these conditions :
You use a URL like this : git#github.com:organization/repo.git
And you run a kind of command like this directly : git clone git#github.com/xxxxx.git whereas you don't have ssh client (or it is not present on path)
Or you have an ssh client installed (and git clone xxx.git work fine on direct command line) but when you run the same kind of command through a shell script file
Here, I assume that you don't want to change protocol ssh git# to http://
(git#github.com:organization/repo.git -> http://github.com/organization/repo.git), like my case, cause I needed the ssh format.
So,
If you do not have ssh client, first of all, you need to install it
If you have this error only when you execute it through a script, then you need to set GIT_SSH_COMMAND variable with your public ssh key, in front of your git command, like this :
GIT_SSH_COMMAND="/usr/bin/ssh -i ~/.ssh/id_rsa" git pull
(Feel free to change it depending on your context)
I had this issue right after my antivirus moved the cygwin ssh binary to virus vault, and restored it after.
Symptoms:
SSH seems properly installed
SSH can be run from command line without problem
Another option before reinstalling ssh in this particular case: check the ssh command permissions
$ ls -al /usr/bin/ssh.exe
----rwxrwx+
$ chmod 770 /usr/bin/ssh.exe
You can try these as well
ssh-add ~/.ssh/identity_file
chmod 400 ~/.ssh/identity_file
It so happened in my case that the new pair of ssh keys linked with my git account were not accessible.
I had to sudo chmod 777 ~/.ssh/id_rsa.* to resolve the issue.