Window 10 connection of Github , SSH issues - github

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

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
Click on the "Settings" gear in the left pane of the Start Menu.
Click on "Apps".
Click on "Optional features".
Look in the list. If you do not see "OpenSSH Client", click "Add a feature".
"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]

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 git#github.com:me/myRepository

Related

Start ssh-agent when windows boots along with ssh passphrase

I have a private Github repo, and I generated the SSH keys using windows.
I am trying to launch ssh-agent when my windows server starts, I can have the following command..
start "" "%PROGRAMFILES%\Git\bin\sh.exe" --login -i
but the problem with this is...I would need to enter the passphrase for my SSH key everytime i reboot.
I am working with a github repo, where whenever we commit a change then it triggers the GIT PULL on the server (using webhooks).
Anyway I can automate this?
You could make sure your .profile (called by sh --login -i) includes a call to ssh-agent with a file:
cat passfile | ssh-add -p keyfile
That way, every time the shell starts, the agent includes your key with its passphrase.

SourceTree Terminal prompting for password but repo authentication is done via SSH

I'm running into an issue where whenver I try to open the terminal for a repository in Sourcetree and I perform a command e.g. git push, I am prompted for a password. The weird thing is that the repository authentication is done via ssh. The normal controls in the GUI work fine for pulling/pushing and doesn't prompt me for a password.
I have set up SSH configuration like so (which works fine for the regular Sourcetree GUI):
As per this thread with a similar issue: https://community.atlassian.com/t5/Sourcetree-questions/ssh-key-in-sourcetree-terminal/qaq-p/137178 I have copied the privkey.ppk to C:\Users\Niels\.ssh\.
Pageant shows the private key as being added too:
Why can I not perform Git operations on my repository from the terminal?
Git uses different format for keys than pagent and pagent is only usable for SourceTree not for Git system. You have to generate a new ssh key with ssh-keygen and you have to add that key to git server you want to use. Open a terminal (GitBash) and apply the following steps:
cd ~/.ssh
ssh-keygen -t rsa -C "your.email#example.com" -b 4096
cat id_rsa.pub | clip
Last command would copy the new public key to the clipboard. You can add it to Git server just bye pasting in the mentioned text box.

Auto push to github without username and password

after much messing around I have followed this tutorial on using a cmd prompt to push up to git hub
http://readwrite.com/2013/10/02/github-for-beginners-part-2
However I have had to do a few things differently. Generating and adding the public key in GitHub went fine, however, adding the private key on my local machine has been a real pain.
I finally added it by opening a cmd prompt as administrator. then going to the directory where github was installed I then rand the following cmds to install the private key
bash
eval $(ssh-agent)
cd to-directory-where-private-.ssh-file-was-located
ssh-add .ssh
Identity added: .ssh (.ssh)
Prior to that I had numerous errors. However, when I run this from a batch file
cd c:/LocalDevelopment/PhoneGap/PfpMetrol
git init
git status
git add PhonegapData.js
git commit -m "Add PhonegapData.js"
git remote -v
git push
pause
it is still asking me for a username and password.

Uploading Folder with images to github

As the title states I was uploading my project to github ( https://github.com/siddhartha-ramesh/FilmReview.git ), but I am stuck here. I cant upload a directory called img to github can anyone help me how to do that. I am not using any gui. Can I create a new folder in github.com just the way I can create new files?
This is what that is happening:
siddhartha#siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git remote add origin git#github.com:siddhartha-ramesh/FilmReview.git
siddhartha#siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git push origin master
The authenticity of host 'github.com (204.232.175.90)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
siddhartha#siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ cd ~
siddhartha#siddhartha-Inspiron-545s ~ $ cd .ssh
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ ssh-keygen -t rsa -C "siddhartharamesh#gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/siddhartha/.ssh/id_rsa): key
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in key.
Your public key has been saved in key.pub.
The key fingerprint is:
#key here
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ cd /home/siddharhta/.ssh
bash: cd: /home/siddharhta/.ssh: No such file or directory
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ cd /home/
siddhartha#siddhartha-Inspiron-545s /home $ cd *
siddhartha#siddhartha-Inspiron-545s ~ $ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
siddhartha#siddhartha-Inspiron-545s ~ $ cd ..
siddhartha#siddhartha-Inspiron-545s /home $ ls
siddhartha
siddhartha#siddhartha-Inspiron-545s /home $ cd siddhartha/
siddhartha#siddhartha-Inspiron-545s ~ $ cd .ssh
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ ls
key key.pub known_hosts
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ cat key
-----BEGIN RSA PRIVATE KEY-----
-----END RSA _________________
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ ls -a
. .. key key.pub known_hosts
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ cat key.pub
ssh-rsa
#key here
siddhartha#siddhartha-Inspiron-545s ~/.ssh $ cd ..
siddhartha#siddhartha-Inspiron-545s ~ $ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
siddhartha#siddhartha-Inspiron-545s ~ $ cd Desktop/
siddhartha#siddhartha-Inspiron-545s ~/Desktop $ ls
Aptana_Studio_3 C_C++ Codes key Untitled Folder WS
siddhartha#siddhartha-Inspiron-545s ~/Desktop $ cd Untitled\ Folder/
siddhartha#siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ ls
film_review
siddhartha#siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git remote add origin git#github.com:siddhartha-ramesh/FilmReview.git
fatal: remote origin already exists.
siddhartha#siddhartha-Inspiron-545s ~/Desktop/Untitled Folder $ git push origin master
To git#github.com:siddhartha-ramesh/FilmReview.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git#github.com:siddhartha-ramesh/FilmReview.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
If you have your folder with your files (pictures in this case) in your local repo (cloned of your github repo), all you need to do to see that folder on GitHub is:
cd /path/to/that/folder
git add .
git commit "add folder with pictures"
git push
# or, if this is your first push:
git push -u origin master
In other words, you add all the files in that folder, and push them.
Instead of trying to add a remote, clone your GitHub repo first, add content in the local clone and push.
Don't use ssh first, use a simpler url based on https, and your login/password:
git clone https://siddhartha-ramesh#github.com/siddhartha-ramesh/FilmReview
cd FilmReview
git config user.name siddhartha-ramesh
git config user.email (your email address used on GitHub)
# add your files
git add .
git commit -m "Add folder"
git push -u origin master
# the next push can be simply 'git push'
GitHub's UI in this respect has not changed in all of these years. If you want to add directories via the GitHub UI, you have to do this:
Select Add file.
Don't pick upload file like you'd think. Instead, select "Create new file".
Up at the top where it says your project name, you should see "Name your file...". Instead of typing the name, type the directory name you're wanting to add and instead of hitting enter, type "/".
Now you need to either add a real file to that directory or just create a fake file name with fake contents. In my case, I just titled it "test.js" with "test" on line 1.
Now, you need to commit the file.
GitHub will create a directory and will upload your new file.
Now if you want, you can delete the test file and your new directory will remain.
Caveat: I'm not sure if you can create a nested directory two levels deep using the "/" trick or not.

How to reset identity file on Mac OS X Snow Leopard

Have not used Github for a while, and would like to reset my identity files on my computer (Mac) so that it can sync up with Github.
Followed the SSH instructions to append the Identity file and chmod to overwrite from Github, but still can't push my repository because Github won't make handshake and recognize the connection.
What is the quickest way to fix this problem?
Here are the results of the ls -l ~~/.ssh ; id command:
~ pdenlinger$ ls -l ~~/.ssh ; id
ls: ~~/.ssh: No such file or directory
uid=501(pdenlinger) gid=20(staff) groups=20(staff),403(com.apple.sharepoint.group.2),204(_developer),100(_lpoperator),98(_lpadmin),81(_appserveradm),80(admin),79(_appserverusr),61(localaccounts),12(everyone),402(com.apple.sharepoint.group.1),401(com.apple.access_screensharing)