Skip to main content

setup git account on mac with ssh - push to remote denied with other login



http://burnedpixel.com/blog/setting-up-git-and-github-on-your-mac/#generatenewkey

SSH uses public-key cryptography to authenticate the remote computer and allow it to authenticate the user, if necessary. There are several ways to use SSH; one is to use automatically generated public-private key pairs to simply encrypt a network connection, and then use password authentication to log on.”
An SSH key basically lets your computer uniquely identify itself when it connects to servers. If Github is aware of the key your computer is using, you won’t have to enter your Github username/password every time you connect.
Check for pre-existing SSH keys on your computer
Let’s see if your computer has one or more keys already installed:

1
2
# Point the terminal to the directory that would contain SSH keys for your user account.
$ cd ~/.ssh
If you get the response “No such file or directory”, skip to Generate a new SSH Key.
Otherwise, you’ll need to backup and remove your existing SSH keys.
Backup and remove your existing SSH keys.

1
2
3
4
5
6
7
8
9
10
11
# Ensure that you are in your ~/.ssh folder
$ cd ~/.ssh

# Make a subdirectory called "key_backup" in the current directory
$ mkdir key_backup

# Copies the id_rsa keypair into key_backup
$ cp id_rsa* key_backup

# Deletes the id_rsa keypair in your ~/.ssh directory
$ rm id_rsa*
Generate a new SSH key
Now we’ll create a new SSH key to use with Github.

1
2
3
4
5
# Ensure that you are in your ~/.ssh folder
$ cd ~/.ssh

# Create a new ssh key using the provided email. The email you use in this step should match the one you entered when you created your Github account
$ ssh-keygen -t rsa -C "your_email@domain.com"
When it asks you to enter a file name in which to save the key, just press return/enter (leave the prompt blank).
You will then be asked to enter a passphrase and confirm it. Don’t make this blank, and don’t make it an easily guessable. This prevents someone from easily acquiring and using your SSH key to impersonate you. Don’t worry, you won’t have to enter this key much (if at all) after initial setup.
Press return after each time you’ve entered your selected passphrase. You won’t see the characters or bullets, the cursor will stay in the same spot as if you aren’t typing.
If you make an error entering your password one of the times, just press return and it will prompt you to try again.
Once you’ve successfully set your passphrase, the terminal will report that your key has been saved and will present you with some sweet ASCII art.
Add your SSH key to Github
In order for your computer to access Github without you having to enter your username/password all the time, Github needs to know the contents of the SSH key you just generated.

1
2
# The below command will copy your newly generated key to your computer's clipboard.
$ pbcopy < ~/.ssh/id_rsa.pub
Now we’ll add your key to Github:
  1. Visit your account settings.
  2. Click Add SSH key.
  3. Enter a descriptive title for the computer you’re currently on, e.g. “Work iMac” into the Title field.
  4. Paste your key into the Key field (it has already been copied to your clipboard).
  5. Click Add Key.
  6. Enter your Github password.
Now let’s test that it all worked.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 # Attempts to connect to Github using your SSH key.
 # Don't change the address shown below
 $ ssh -T git@github.com

 # You may see the following warning:
 The authenticity of host 'github.com (207.97.227.239)'
 cant 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)?

 # Type yes and press return
 # You may have to enter your recently selected passphrase.

 # You should then see:
 Hi username! You've successfully authenticated,
 but GitHub does not provide shell access.

Comments

Popular posts from this blog

About GraphQL - Downside

Web caching complexity

File uploading. Since GraphQL doesn’t understand files, a file uploading feature is not included in its specification. You won’t have to deal with this limitation in case of REST, as there you can POST or PUT whatever content you want to.
To allow file uploads in your GraphQL web app, there are several options: using Base64 encoding. But it will make the request larger and expensive to encode/decode.making a separate API endpoint just for this purpose.using a library like Apollo for implementing the GraphQL multipart request specification.uploadFileToS3:combineResolvers( // isAuthenticated, async (parent, args, { models }) => { const { file } = awaitargs const { createReadStream, filename, mimetype, encoding } = awaitfile conststream = createReadStream() constresult = awaituploadFileToS3(filename, stream) returnresult } ),