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

for loop in javascript - promise - .eslintrc for "for of"

the vast majority of cases  map ,  forEach ,  find  etc. can be used.  async function printFiles () { const files = await getFilePaths(); await Promise.all(files. map (async (file) => { const contents = await fs.readFile(file, 'utf8') console.log(contents) })); } const inventory = [ { name : 'apples' , quantity : 2 } , { name : 'bananas' , quantity : 0 } , { name : 'cherries' , quantity : 5 } ] ; const result = inventory . find ( ( { name } ) => name === 'cherries' ) ;   function getFirstMatching(array) { for (let item of array) { const result = heavyTransform(item); if (result) { return result; } } } Specifically this shuts down the whole no-restricted-syntax. If you want to cherry-pick, here is the current definition: 'no-restricted-syntax' : [ 'error' , { selector : 'ForInStatement' , message...

Apollo client - cache APIs - auto update cache - erase cache - reactive variables - deletion - addition

Apollo Client 3  Local only fields Reactive Variables const cache = new InMemoryCache ( { typePolicies : { Todo : { // If one of the keyFields is an object with fields of its own, you can // include those nested keyFields by using a nested array of strings: keyFields : [ "date" , "user" , [ "email" ] ] , } } , } ) ; This internal data is intended to be easily  JSON-serializable , so you can take a snapshot with  cache.extract() , save it somewhere, and later restore with  cache.restore(snapshot) . Here’s a mutation called  EditTodo  that returns the new  todo  value in the mutation response. mutation EditTodo ( $id : Int ! , $text : String ! ) { editTodo ( id : $id , text : $text ) { success todo { # <- Returning it here id text completed } error { ... on TodoNotFoundError { message } ... on TodoValidationE...

window.URL.createObjectURL is not (yet) available in jest-dom - testing scenario

Since  window.URL.createObjectURL  is not (yet) available in jest-dom, you need to provide a mock implementation for it. Don't forget to reset the mock implementation after each test. describe ( "your test suite" , () => { window . URL . createObjectURL = jest . fn (); afterEach (() => { window . URL . createObjectURL . mockReset (); }); it ( "your test case" , () => { expect ( true ). toBeTruthy (); }); });