1, input in Terminal: CD ~/.ssh if-BASH:CD:/users/glamor/.ssh:no such file or directory, you have not used it before. Take the second step directly.
If you have previously used the need to clean up the original RSA, execute the command: mkdir key_backup $ cp id_rsa* Key_backup $ rm id_rsa*
Last Login:mon Dec 5 20:27:47 on ttys000
glamordemac-mini:~ glamor$ CD ~/.ssh
-BASH:CD:/users/glamor/.ssh:no such file or directory
glamordemac-mini:~ glamor$ ssh-keygen-t rsa-c "[Email protected]"
Bad escape character ' Ygen '.
2, execute command: ssh-keygen-t rsa-c [email protected]
glamordemac-mini:~ glamor$ ssh-keygen-t rsa-c [email protected]
Generating public/private RSA key pair.
Enter file in which to save the key (/USERS/GLAMOR/.SSH/ID_RSA):
Created directory '/users/glamor/.ssh '.
Enter passphrase (empty for no passphrase):
Enter same Passphrase again:
Your identification has been saved In/users/glamor/.ssh/id_rsa.
Your public key has been saved in/users/glamor/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:JB+WPQ364SLLU17H8SYOQDIQ1YMOWZNNTFCDNAFTJFI [email protected]
The key ' s Randomart image is:
+---[RSA 2048]----+
| .. oo=. |
| . .. =*o |
| boo*o.o |
| B o*. O. |
| * B. s+ |
| +.O.O.O E |
| . OO.O * |
| .. Oo. + |
| O ... |
+----[SHA256]-----+
glamordemac-mini:~ glamor$
3. Locate the public key that was just generated by/users/glamor/.ssh/id_rsa.pub. Path. If some hidden files are not displayed by default, use defaults write Com.apple.finder appleshowallfiles-bool true
command, if not effective in real time, it is recommended to click on the small apple, forced exit Finder, restart the Finder after the nature of all the files are seen.
4, Login to GitHub account, click Settings, go to find personal settings. Click SSH and GPG keys. After you add your own SSH public key to the SSH server (github.com), github.com this SSH key with
Your github account is linked and your machine (Mac git client) will have write permission to push the commit code to the remote repository in your GitHub account name.
Click New SSH key to:
Fill in the title and paste the public key content you just generated into key. Click Add SSH Key.
5. Test connection: ssh-t [email protected], Hi jacklearning! You've successfully authenticated, but GitHub does not provide shell access. Indicates that the connection was successful.
But the GitHub does not provide shell access is because of the HTTPS mode provided by GitHub, not SSH, check the remote URL of your git repository and see which connection is being used.
glamordemac-mini:~ glamor$ ssh-t [email protected]
The authenticity of host ' github.com (192.30.253.112) ' can ' t be established.
RSA key fingerprint is sha256:nthbg6kxupjwgl7e1igocspromtxdcarlvikw6e5sy8.
Is you sure want to continue connecting (yes/no)? Y
Please type ' yes ' or ' no ': Yes
warning:permanently added ' github.com,192.30.253.112 ' (RSA) to the list of known hosts.
Hi jacklearning! You've successfully authenticated, but GitHub does not provide shell access.
6. Set up user information.
glamordemac-mini:~ glamor$ git config--global user.name "jacklearning"
glamordemac-mini:~ glamor$ git config--global user.email "[Email protected]"
7. Git clone yii2
Before configuring SSH, you can get the Yii open source framework by: Git clone https://github.com/yiisoft/yii2.git
After configuring SSH, you can get the Yii open source framework by: git clone [email protected]:yiisoft/yii2.git and git clone https://github.com/yiisoft/yii2.git
Appendix:
Git and OpenSSH preinstalled on Mac
Ssh--secure Shell (Secure Shell Protocol)
SSH is based on the application layer and Transport layer, the default port is 22, for remote login sessions and other network services to provide security protocols. SSH is an industry standard that overrides Telnet (the default port is 23) and other remote console management applications.
The SSH service was first developed by a Finnish company in a UNIX system, and then quickly expanded to other operating platforms, and has now evolved to the SSH2 version. SSH is only a protocol, there are many implementations, both commercial and open source implementation. As a result of copyright and encryption algorithms and other factors, many people began to switch
Open source Free OpenSSH (Linux/mac OS x standard).
SSH provides a key-based authentication mechanism, and you must create a pair of asymmetric keys for yourself (public/private key pair) and place the public key on the server that needs to be accessed for authorization. SSH1 uses RSA (RonRivest, AdiSHamir, LeonardAdleman) encryption keys, SSH2 use
DSA (digital Signature algorithm, digitally signed algorithm) key protection connection and authentication. Both RSA and DSA encryption algorithms are non-symmetric encryption algorithms.
The so-called "SSH Public key authentication Password-Free login authentication mechanism ", the principle is as follows:
(1) The SSH client stores the SSH public key in advance on the remote SSH server, and then the SSH client carries the public key to initiate the login request to the remote SSH server (known_hosts).
(2) After the remote SSH server receives the request, the Authorized_keys on the server first looks for you to upload the authorized public key, then compares it with the public key that you sent over.
(3) If two public keys are the same (key Exchange Success), the remote SSH server sends the user an Identity Challenge (challenge) by sending a random string encrypted with the SSH public key.
(4) SSH client uses its own private key to decrypt and then send back to the remote SSH server, the remote SSH server compared to the packet back to decrypt the random string is consistent. If consistent, it proves that the user (public key or identity) is trustworthy, directly allowing the login shell to no longer require a password.
Use SSH (key) to access GitHub under Mac