Git Generating A New Ssh Key Git Local Directory
If you're unsure whether you already have an SSH key, check for existing keys. If you don't want to reenter your passphrase every time you use your SSH key, you can add your key to the SSH agent, which manages your SSH keys and remembers your passphrase. Generating a new SSH key. Open Terminal Terminal Git Bash the terminal. I have an SSH key saved in D:/keys folder. I want to add it to my git bash. All the tutorials I found is how to generate SSH key using gitbash and load it to github/gitlab. I generated my SSH key u. An SSH key is an access credential for the SSH (secure shell) network protocol. This authenticated and encrypted secure network protocol is used for remote communication between machines on an unsecured open network. SSH is used for remote file transfer, network management, and remote operating system access. Cannot clone any git repository from git bash with SSH key duplicate. There I followed the 'Generating a new SSH key and adding it to the ssh-agent' step (before that the.ssh folder already existed with only a known-hosts file in it). 'Once you have your key set in home/.ssh directory (or Users/.ssh under windows), open it.
Notes on using Git and GitHub. Just the essentials.
- Using Git on a Windows PC
- Using Git with GitHub
GitHub tutorial
GitHub online
https://github.disney.com
or
https://github.com (generic)
Click Sign up or Sign inEnter your Username or Email & password
From the home page:
Click an existing repository, orClick the green box:
+ New repository
Add the repository name
Click and edit the README file
Other GitHub features are mostly click-able - navigate and explore as desired.
Using Git on a Windows PC
Install Git for Windows:https://git-scm.com
Accept all the defaults; add the Git Bash icon to your desktop / taskbar
The Git Bash shortcut properties are:
Using the Git shell
- Click the icon to open the Git Bash shellA MINGW64 terminal window will open and display a prompt similar to:
James@DESKTOP-6N4UAR1 MINGW64 ~/<path to your current directory>
$
Common Git CommandsThe Git shell is like a ssh environment:
pwd
- shows you the present working directory
cd /c/Dropbox/
- change to C:Dropbox directory
ls -al
- list all files in the current directory
git remote -v
- show the 'handles' for your remote connections - v = verbose
git help git
- dipslay the help index
git help <command>
- display help for specific commands
git help git
- opens an online man page on git
First time setupThe first time you use the git command shell, run these commands to save these to the environment so you don't have to do it again:
Using Git with GitHub
Note: If this is your first time using Git, you may need to set up authentication:Configuring Git Authentication
Fork an existing repository
This is the process of 'forking' (getting a copy of) an existing repository from GitHub.com to a local PC directory. After you have a local copy on your PC, you can edit/add/delete files and then 'push' them back to the repository on GitHub.
Start the Git Bash shell
Create and/or change directory to where you'd like to create a copy of the repository on GitHubNote! The git clone command will create a new directory inside this folder with the same name as the repository on GitHub - so don't create and CD to the directory you anticipate the files to reside in.
Open a new browser window pointed to the GitHub repository:
A generic GitHub login:
https://github.comor the Disney Enterprise Monitoring repository:
https://github.disney.com/WDPR-EnterpriseMonitoringor if you want to use a personal GitHub account (substitute your LANID):
https://github.disney.com/BAXTJ018/Click to navigate to the repository you want to 'fork' (download a copy of)
Click the Green 'Clone or download' button and copy the URL to your clipboard - for example:
(this is the repository structure on GitHub)
Paste this entire
git clone https://...
command into the Git shell on your PC.If you have the proper authentication set up, you should see messages that indicate a copy of the repository is being created on your PC.
ls -al
- the new repository directory should show upChange directory to the new repository directory
cd /<new folder>
ls -al
- you should see .git and a README.md and other repository files
Push to the repository
After you have edited / added / deleted files in your local PC directory, you can update the files in the GitHub repository.
Get the local Git status:
git status
- creates a list of files that have been modified/added/deletedIndicate that you want Git to track all the files in your local directory:
git add .
You could also indicate specific files only:git add <filename>
Commit everything that has been 'staged' and add a message (mandatory):
git commit -m 'latest updates'
Push the file updates to the GitHub repository:
git push origin master
You may be prompted for your username and password
Configuring Git Authentication
You will have to add a ssh key to git hub - follow the instructions on the link below:https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
Generating a new SSH key and adding it to the ssh-agent
MAC WINDOWS LINUX
After you've checked for existing SSH keys, you can generate a new SSH key to use for authentication, then add it to the ssh-agent.
If you don't already have an SSH key, you must generate a new SSH key. If you're unsure whether you already have an SSH key, check for existing keys.
If you don't want to reenter your passphrase every time you use your SSH key, you can add your key to the SSH agent, which manages your SSH keys and remembers your passphrase.
Generating a new SSH key
Open Git Bash.
Paste the text below, substituting in your GitHub email address.
ssh-keygen -t rsa -b 4096 -C 'your_email@example.com'
This creates a new ssh key, using the provided email as a label.
Generating public/private rsa key pair
When you're prompted to 'Enter a file in which to save the key,' press Enter. This accepts the default file location.
Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter]
At the prompt, type a secure passphrase. For more information, see 'Working with SSH key passphrases'.
Enter passphrase (empty for no passphrase): [Type a passphrase]Enter same passphrase again: [Type passphrase again]
Ssh Key Generation Linux
Adding your SSH key to the ssh-agent
Git Ssh Gen
Before adding a new SSH key to the ssh-agent to manage your keys, you should have checked for existing SSH keys and generated a new SSH key.
If you have GitHub Desktop installed, you can use it to clone repositories and not deal with SSH keys. It also comes with the Git Bash tool, which is the preferred way of running git commands on Windows.
Ensure the ssh-agent is running:
If you are using the Git Shell that's installed with GitHub Desktop, the ssh-agent should be running.If you are using another terminal prompt, such as Git for Windows, you can use the 'Auto-launching the ssh-agent' instructions in 'Working with SSH key passphrases', or start it manually:
start the ssh-agent in the background
eval $(ssh-agent -s)
Agent pid 59566
Add your SSH key to the ssh-agent. If you are using an existing SSH key rather than generating a new SSH key, you'll need to replace id_rsa in the command with the name of your existing private key file.
$ ssh-add ~/.ssh/id_rsa
Next Step: Add the SSH key to your GitHub account
###Adding a new SSH key to your GitHub account
MAC WINDOWS LINUX
To configure your GitHub account to use your new (or existing) SSH key, you'll also need to add it to your GitHub account.
Before adding a new SSH key to your GitHub account, you should have:
Checked for existing SSH keysGenerated a new SSH key and added it to the ssh-agentNote: DSA keys were deprecated in OpenSSH 7.0. If your operating system uses OpenSSH, you'll need to use an alternate type of key when setting up SSH, such as an RSA key. For instance, if your operating system is MacOS Sierra, you can set up SSH using an RSA key.
Copy the SSH key to your clipboard.
If your SSH key file has a different name than the example code, modify the filename to match your current setup. When copying your key, don't add any newlines or whitespace.
$ clip < ~/.ssh/id_rsa.pub
Copies the contents of the id_rsa.pub file to your clipboard
Tip: If clip isn't working, you can locate the hidden .ssh folder, open the file in your favorite text editor, and copy it to your clipboard.
Settings icon in the user bar in the upper-right corner of any page, click your profile photo, then click Settings.
Authentication keysIn the user settings sidebar, click SSH and GPG keys.
SSH Key buttonClick New SSH key or Add SSH key.
In the 'Title' field, add a descriptive label for the new key. For example, if you're using a personal Mac, you might call this key 'Personal MacBook Air'.The key fieldPaste your key into the 'Key' field.The Add key buttonClick Add SSH key.
Sudo mode dialog
If prompted, confirm your GitHub password.
$ git clone git@github.disney.com:BAXTJ018/SplunkOnAWS.git
is not the same repository as
Windows Git Ssh Key
$ git clone git@github.disney.com:WDPR-EnterpriseMonitoring/SplunkOnAWS.git
Getting it to work
- Start Git Bash
- cd to directory containing slave files
- git status
- Edit / Add / Delete files
Written with StackEdit.