- Github ssh key macOS Sierra
- 2 Answers 2
- How to Install Git on Mac and Generate SSH Keys
- Amir Ghahrai
- How to Install Git on Mac
- How to generate SSH key for GitHub authorization
- How to access and copy public SSH key
- How to upload your public SSH key to GitHub
- cham11ng / git-ssh-configuration.md
- Macintosh Git SSH key setup
- Generating a new SSH key and adding it to the ssh-agent
- Help us make these docs great!
Github ssh key macOS Sierra
I’ve been able to follow the steps of
- ssh-keygen -t rsa -b 4096 -C «your_email@example.com»
- eval «$(ssh-agent -s)»
However from this part onwards, nothing works
I do not understand what they mean by «modify your
/.ssh/config file » & the Host * AddKeysToAgent yes UseKeychain yes IdentityFile
/.ssh/id_rsa does not work on terminal either, as the results says ‘no such file or directory’
I saved the key file to my Desktop folder when ssh-keygen prompted me for a location.
2 Answers 2
When you did an ssh-keygen , you would have been prompted for the location to save the keys in. It is by default
/.ssh/ . If you saved them somewhere else, you should try locate id_rsa and then do ssh-add
Move the key to .ssh where it belongs, and/or create a .ssh/config file and tell it where to look for the key.
If .ssh doesn’t exist, you have to create it first, obviously.
You can just copy/paste these commands to the Terminal, though putting them in a file like /tmp/sshcommands and running it with bash /tmp/sshcommands might be slightly less jarring.
Obviously, you should read up on these commands enough to understand at least roughly what’s going on here. Probably the key realization is that ssh doesn’t know you have a Desktop folder and would not want to look there for the key even if it knew. (You could change the final IdentityFile statement to actually change that, but really, at this point you are better off learning the standard practice.)
Источник
How to Install Git on Mac and Generate SSH Keys
Amir Ghahrai
In this step-by-step Git Tutorial, we will go through how to install Git on a Mac machine, how to generate SSH keys and upload your public SSH key to your GitHub account for authorization.
How to Install Git on Mac
Open a terminal and type
This will install Git on your system. To confirm the installation, type
This will print the version of Git installed on your machine.
How to generate SSH key for GitHub authorization
- Open a terminal
- Go to your home directory by typing cd
Type the following command ssh-keygen -t rsa
- This will prompt you to enter a filename to store the key
- Just press enter to accept the default filename (/Users/you/.ssh/id_rsa)
- Then it will ask you to create a passphrase. This is optional, either create a passphrase or press enter for no passphrase
/.ssh/id_rsa.pub
Your public key is stored in the file ending with .pub, i.e.
How to access and copy public SSH key
In order to authenticate yourself and your device with GitHub, you need to upload your public SSH key which you generated above to your GitHub account.
Copy public SSH key
Open a terminal and type
This will copy the contents of the id_rsa.pub file to your clipboard.
How to upload your public SSH key to GitHub
- Once you have copied your public SSH key, login to your GitHub account and go to
- https://github.com/settings/profile
- On the left-hand side menu, you will see a link “SSH and GPG keys”
- Click on that link which will take you to a page where you can enter your public SSH key that you copied earlier.
- Click the button which says ‘New SSH key’
- Then enter a title name — can be anything, e.g. newMac
- Paste the public SSH key in the key textbox
- Click “Add SSH key”
Test your GitHub authorization:
Open a terminal and type
- It will ask you if you want to continue to connect, type yes
- If you created a passphrase when you were generating the public key, then it will ask you to enter it.
- Enter your passphrase and press enter.
- It will then start to clone the project to your directory.
You are all now set up to use Git and GitHub.
Источник
cham11ng / git-ssh-configuration.md
Git Installation and SSH Configuration
Installation
We can check if Git is installed by typing git —version in your Terminal or Git Bash (Windows) respectively.
Download Git for Windows from this link https://git-scm.com/downloads
Configuration
Set up SSH for Git
Open your Terminal or Git Bash(Windows).
- Ensure we have SSH client installed:
List the contents of your
If we have already setup default identity, we can see two id_ files
- Set up our default identity:
The system adds keys for all identities to the /home/ /.ssh (Linux) or /c/Users/ /.ssh (Windows) directory. The following procedure creates a default identity.
Hit ssh-keygen command on Terminal or Git Bash.
Press enter to accept the default key and location or we can set somewhere else.
We enter and re-enter a passphrase when prompted. Unless you need a key for a process such as script, you should always provide a passphrase. The command creates your default identity with its public and private keys
List the contents of your
- Adding your SSH key to the ssh-agent:
Ensure ssh-agent is enabled:
Add your SSH key to the ssh-agent
- Find and take a note of your public key fingerprint. If you’re using OpenSSH 6.7 or older:
- Install the public key on your Remote GitHub/Bitbucket account:
Copy this output to respective SSH keys setting.
- GitHub Setting >> SSH and GPG keys >> New SSH key
- Bitbucket Setting >> SSH keys >> Add Key
You have now successfully configured SSH for Git in Windows/Linux/Mac OS.
Источник
Macintosh Git SSH key setup
I use Linux, I help some students that have Macintosh. I can coach them through the command line part, but on some Mac setup things I’m helpless.
On a Macintosh, we follow instructions here https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent. We are able to generate SSH keys, upload the public part, and then we can interact with GitHub. We are able to accomplish same in Gitlab servers or BitBucket.
Here is a part I don’t understand. In the newer Mac OS, the user accounts don’t have ssh-agent launched within each session and the user key is not remembered. As far as I can tell, when a user wants to interact with GitHub or some other Git remote using ssh protocols, it is necessary to run these two lines the terminal:
That’s tedious, but as far as I can see it is the state of the Mac world. https://github.com/lionheart/openradar-mirror/issues/15361. This is somewhat inconvenient. Even if we put them in a shell script, not awesome.
I’d like to put same in the shell configuration, don’t know how.
Linux systems always start ssh-agent for us and we never notice this inconvenience, I gather.
I have asked several more senior Mac users and they say they don’t see this problem, that Git and SSH keys just work. I’m trying to find out what is different in their systems. My best guess so far is that they created keys without any passphrases, in which case the thing might work without ssh-agent. I’ll ask one of them to try that and see.
If you have other ideas about what to do, I’d appreciate ideas.
Источник
Generating a new SSH key and adding it to the ssh-agent
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.
About SSH key generation
If you don’t already have an SSH key, you must generate a new SSH key to use for authentication. If you’re unsure whether you already have an SSH key, you can check for existing keys. For more information, see «Checking for existing SSH keys.»
If you want to use a hardware security key to authenticate to GitHub, you must generate a new SSH key for your hardware security key. You must connect your hardware security key to your computer when you authenticate with the key pair. For more information, see the OpenSSH 8.2 release notes.
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 .
Paste the text below, substituting in your GitHub email address.
Note: If you are using a legacy system that doesn’t support the Ed25519 algorithm, use:
This creates a new SSH key, using the provided email as a label.
When you’re prompted to «Enter a file in which to save the key,» press Enter. This accepts the default file location.
At the prompt, type a secure passphrase. For more information, see «Working with SSH key passphrases.»
Adding your SSH key to the ssh-agent
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. When adding your SSH key to the agent, use the default macOS ssh-add command, and not an application installed by macports, homebrew, or some other external source.
Start the ssh-agent in the background.
Depending on your environment, you may need to use a different command. For example, you may need to use root access by running sudo -s -H before starting the ssh-agent, or you may need to use exec ssh-agent bash or exec ssh-agent zsh to run the ssh-agent.
If you’re using macOS Sierra 10.12.2 or later, you will need to modify your
/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.
First, check to see if your
/.ssh/config file exists in the default location.
If the file doesn’t exist, create the file.
/.ssh/config file, then modify the file to contain the following lines. If your SSH key file has a different name or path than the example code, modify the filename or path to match your current setup.
Note: If you chose not to add a passphrase to your key, you should omit the UseKeychain line.
Note: If you see an error like this
add an additional config line to your Host * section:
Add your SSH private key to the ssh-agent and store your passphrase in the keychain. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.
Note: The -K option is Apple’s standard version of ssh-add , which stores the passphrase in your keychain for you when you add an SSH key to the ssh-agent. If you chose not to add a passphrase to your key, run the command without the -K option.
If you don’t have Apple’s standard version installed, you may receive an error. For more information on resolving this error, see «Error: ssh-add: illegal option — K.»
Add the SSH key to your account on GitHub. For more information, see «Adding a new SSH key to your GitHub account.»
If you have GitHub Desktop installed, you can use it to clone repositories and not deal with SSH keys.
Ensure the ssh-agent is running. You can use the «Auto-launching the ssh-agent» instructions in «Working with SSH key passphrases», or start it manually:
Add your SSH private key to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.
Add the SSH key to your account on GitHub. For more information, see «Adding a new SSH key to your GitHub account.»
Start the ssh-agent in the background.
Depending on your environment, you may need to use a different command. For example, you may need to use root access by running sudo -s -H before starting the ssh-agent, or you may need to use exec ssh-agent bash or exec ssh-agent zsh to run the ssh-agent.
Add your SSH private key to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.
Add the SSH key to your account on GitHub. For more information, see «Adding a new SSH key to your GitHub account.»
Generating a new SSH key for a hardware security key
If you are using macOS or Linux, you may need to update your SSH client or install a new SSH client prior to generating a new SSH key. For more information, see «Error: Unknown key type.»
Insert your hardware security key into your computer.
Open Terminal Terminal Git Bash .
Paste the text below, substituting in the email address for your account on GitHub.
Note: If the command fails and you receive the error invalid format or feature not supported, you may be using a hardware security key that does not support the Ed25519 algorithm. Enter the following command instead.
When you are prompted, touch the button on your hardware security key.
When you are prompted to «Enter a file in which to save the key,» press Enter to accept the default file location.
When you are prompted to type a passphrase, press Enter.
Add the SSH key to your account on GitHub. For more information, see «Adding a new SSH key to your GitHub account.»
Help us make these docs great!
All GitHub docs are open source. See something that’s wrong or unclear? Submit a pull request.
Источник