Skip to content

Instantly share code, notes, and snippets.

@GrennKren
Last active August 5, 2024 07:29
Show Gist options
  • Save GrennKren/a724e2ff9d71a113d626bed0719c4cdb to your computer and use it in GitHub Desktop.
Save GrennKren/a724e2ff9d71a113d626bed0719c4cdb to your computer and use it in GitHub Desktop.
Handling git problem and others on Windows Server
client side:
generate key with:
`$ ssh-keygen -i ed25519`
take the content of id_ed25519.pub
and append it into authorized_keys (the path can be found in config file)
server side:
check config file
"C:\ProgramData\ssh\sshd_config"
for
PubkeyAuthentication
AuthorizedKeysFile
Client Side:
If you get the error message:
fatal: ''/D:/project/myrepo'' does not appear to be a git repository
when trying to clone a git repository via SSH using OpenSSH on a Windows Server, for example:
`$ git clone ssh://[email protected]:22110/D:/project/myrepo`
#####################################################################
Server side:
Make sure D:/project/myrepo has been initialized with `git init`, and change the default shell of OpenSSH from powershell to bash.exe, which comes with git-bash.
Open regedit
Go to `HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH` and add a new String Value C:\Program Files\Git\usr\bin\bash.exe without double quotes ' " '
Server (Local repo, has SSH [email protected], and to handle git pull request from sub computers):
- create a folder
- `$ git init --bare`
Main Computer (not the server, to handle git pull from master github):
- `$ git clone https://github.com/xxx/yyyy` (the repo from github)
- `$ git remote -v` (check origin urls )
should get something like this
```
origin https://github.com/xxx/yyyy (fetch)
origin https://github.com/xxx/yyyy (push)
```
fetch is the one to git pull from master github
push is the one to push changed/update
- need to change that push into server local repo
`$ git remote set-url --add --push origin "ssh://[email protected]/C:/the_location_git_that_was_just_git_init_bare"` (to add)
`$ git remote set-url --delete --push origin "ssh://[email protected]/C:/the_location_git_that_was_just_git_init_bare"` (to remove)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment