Home > Software engineering >  Window 10 connection of Github , SSH issues
Window 10 connection of Github , SSH issues

Time:01-08

I am trying to connect git to GitHub. I am using window 10. The SSH directory is not available.

$ cd .ssh
bash: cd: .ssh: No such file or directory

How can I connect the git to github?

Screenhot of git to github ssh connection problem

enter image description here

CodePudding user response:

Windows 10 systems with build 1803 or newer and Windows Server 2019 come with an implementation of OpenSSH that's enabled by default. Some older versions may have this as an optional component that needs to be installed before it can be used.

Looks like in your case it may need to be installed (see if the folder "C:\Windows\System32\OpenSSH" exists and has files such as "ssh.exe" in it). If it is installed, then that directory needs to be added to the search path (type "echo %PATH%" in the command prompt window to see if it's in there).

Installation

  1. Click on the "Settings" gear in the left pane of the Start Menu.
  2. Click on "Apps".
  3. Click on "Optional features".
  4. Look in the list. If you do not see "OpenSSH Client", click "Add a feature".
  5. "OpenSSH Client" and click "Install".

On analyzing deeper into the issue, it looks like you are searching or trying to cd to .ssh on the desktop which won't work.

Additionally, it looks like you are doing cat to a file that may not have existed as you have never generated public-private key pair(See ssh-keygen command for details)

Just try typing ssh and press enter to see that if it is actually the problem with ssh.

It should give output as(or similar to) :-

$ ssh
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
           [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
           [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
           [-i identity_file] [-J [user@]host[:port]] [-L address]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-Q query_option] [-R address] [-S ctl_path] [-W host:port]
           [-w local_tun[:remote_tun]] destination [command]

CodePudding user response:

The .ssh directory is generally not available.
Not until you create it and use it with ssh-keygen (the one packaged with Git for Windows at C:\Program Files\Git\usr\bin\ssh-keygen.exe)

From a simple CMD:

cd %USERPROFILE%
mkdir .ssh
C:\Program Files\Git\usr\bin\ssh-keygen.exe -t rsa -P ""

You will get a:

  • %USERPROFILE%\.ssh\id_rsa (private key)
  • %USERPROFILE%\.ssh\id_rsa.pub (public key)

Copy the latter (the public key content) to your GitHub profile: that is how you associate Git to your GitHub account.

From there, you can open a Git bash session, and git clone using an SSH URL.

git clone [email protected]:me/myRepository
  • Related