Why can the Git Shell use SSH with an HTTP remote origin URL? - powershell

I have read Configuring Git over SSH to login once. Muein Muzamil's answer says that to use SSH, we must configure as follows:
remote.origin.url=git#github.com:your_username/your_project.git
Which is to say, that in a normal Windows PowerShell, SSH does not work with HTTPS.
GitHub for Windows comes with the Git Shell. It's a souped-up PowerShell with some fancy features, including the ability to use SSH with HTTP. I know this because I just ran git push without needing to authenticate, and then ran git config -l to see that I am using HTTPS as the remote origin url.
Why does a normal Windows PowerShell require the git#github.com protocol whereas a Git Shell does not?

Windows PowerShell, SSH does not work with HTTPS
That doesn't make sense: you are using ssh or you are using https (http with ssl). One "does not work with" the other.
G4W (GitHub for Windows) has your GitHub account credentials, so it can use an https url.
A regular Git shell from msysgit/Git for Windows can use https or ssh, BUT for ssh, you need to make sure that:
the environment variable %HOME% is defined (which git-cmd.bat or git-bash.vbs do for you),
your id_rsa(.pub) private/public ssh keys are in it,
your id_rsa.pub public key is published in your GitHub account.

Related

How to use SSH connect Gitea and SourceTree?

now I long to build a private git server myself by gitea and use SourceTree as a git GUI (on Windows)
Current situation & steps:
1.I've already set up a host with gitea, and create a repos here.
2.I used SourceTree (putty) to create a public SSH key and save the .ppk file.
3.Adding this SSH on gitea page (something might be wrong because there is a verification button)
4.Using Pageant.exe on client to add key
5.Using SourceTree and try to clone the new repos by SSH
6.However, SourceTree on Client can not recognize the url
note:
1.both two computers connect to Local Area Network
2.opening port:3000 on host is done, and using "telnet HOSTNAME 3000" on client is successful
3.error message when using git command is here
Is there any step I did wrong?

Error in the checkout of a Github using Subversion with SSH - Linux Command line

Github recently enforced a no password rule with their repository access. I can't do two factor authentication, so, I am stuck with SSH keys. I want to use subversion, but when I try to checkout my repo, using:
svn co "svn+ssh://git#github.com/Oiubrab/ozzymandais.git"
I get the error:
Invalid command: 'git#github.com svnserve -t'
You appear to be using ssh to clone a git:// URL.
Make sure your core.gitProxy config option and the
GIT_PROXY_COMMAND environment variable are NOT set.
svn: E170013: Unable to connect to a repository at URL 'svn+ssh://git#github.com/Oiubrab/ozzymandais.git'
svn: E210002: To better debug SSH connection problems, remove the -q option from 'ssh' in the [tunnels] section of your Subversion configuration file.
svn: E210002: Network connection closed unexpectedly
From the research I've done, I think I need to edit the /home/user/.subversion/config file, but i have no idea how and there is no documentation as to how to use svn with github with ssh. I have setup an ssh key and popped it on my github account. I just need to know how to setup the subversion tunnel to github.
I don't think that github supports the svnserve protocol.
AFAIK, you should generate a personal access token (PAT) in GitHub and use it as a password in the Subversion client. I.e., enter your PAT when the client prompts you for a password.

Pushing to GitHub without a key

I am using GitHub and C9 on a work computer and but GitHub will stop reading my SSH key after a few hours. IDK if it is because I am using my work computer (job is not currently programming), but is there a way I can push my code without an SSH key
First, check that your remote URL is indeed an ssh one:
cd /path/to/my/local/cloned/repo
git remote -v
If it is (git#github.com:user/repo), check what ssh -Tv git#github.com returns.
If SSH does not work (because SSH port might be blocked at work), switch to an HTTPS URL:
git remote set-url origin https://github.com/user/repo
From there, make sure git config credential.helper does reference an helper (like "manager" on Windows), and you will be prompted for your GitHub account username/password at the first push. After that, your credentials will be cached.

Private Github Repositories with Envoy

Anybody has any problems deploying with Laravel's envoy when using private Github repos?
When manually cloning my repo from the production server, the ssh key seems to be accessible but when using Envoy, I always get a "Permission denied (publickey) error.
Thanks
It is probably because the ssh key on your remote server requires a password.
If you change the Envoy.blade.php to perform some other task you should be able to establish whether you are connecting to your remote correctly.
#servers(['web' => 'user#domain.com'])
#task('deploy')
cd /path/to/site
git status
#endtask
Should return something like:
[user#domain.com]: On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
If you are connecting using a Mac or Linux you probably don't have to enter your password because your terminal is using ssh-agent which silently handles your authentication.
Wikipedia article on ssh-agent
When connecting over ssh, ssh-agent isn't running and the script is being prompted for a password which is where it is failing.
To get around this you could to generate a new key on the remote machine that doesn't use a password.
If you want to restrict the ssh key to a single repository on GitHub have a look at deploy keys
You need to pass the -A (as per the man page it - Enables forwarding of the authentication agent connection. This can also be specified on a per-host basis in a configuration file) in you ssh string.
You will also need add your ssh key for agent forwarding (on the machine which can access the git remote which I assume be your localhost)
ssh-add -K ~/.ssh/your_private_key
Something like this
#servers(['web' => '-A user#domain.com'])
#task('deploy')
cd /path/to/site
git status
#endtask
Git remote commands should now work.

How do I specify the key file that capistrano will use when cloning the repository on the remote server?

Ideally, I want something like set :scm_keyfile, "~/.ssh/server-deploy-key". The path specified would of course be a path on the remote server.
If the remote user already has a ~/.ssh/id_rsa or ~/.ssh/id_dsa then git will use it by default.
If you wish to use an alternate file name for your private key, you can do this. Create a file on your remote server ~/.ssh/config and put these lines in it
Host github.com
User git
IdentityFile ~/.ssh/server-deploy-key
Now when you attempt to run a command like git clone git#github.com/xxx/yyy.git, Your ~/.ssh/server-deploy-key will be used.
Another method is to use ssh-agent forwarding. In this method, you don't need to put your deploy key on the remote server. As long as it is on your local machine, and you have enabled ssh-agent forwarding, your remote server will have access to the key and will use it . There is a nice article on github explaining this.