How to implement SSH login to Linux host on Mac OS x

Source: Internet
Author: User
Tags scp command



Reprint NOTE: This article reprinted from http://www.aips.me/mac-key-ssh-login-linux.html


    1. Generate key Pair
    2. Log in to the remote host with a password, copy the public key past
    3. Done





First step: Generate key Pair
Execute Command ssh-keygen-t RSA
The results of the implementation are as follows:



[email  protected]:~ > ssh-keygen-t RSA
Generating public/private RSA key pair.
Enter file in which to save the key (/users/charles/.ssh/id_rsa):
Created directory '/users/charles/.ssh '.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification have been saved In/user S/charles/.ssh/id_rsa.
Your Public Key has been saved in/users/charles/.ssh/id_rsa.pub.
The key fingerprint is:
c8:4b:85:87:90:7c:1 this section kdy hidden .... [Email protected]
The key ' s Randomart image is:
+–[RSA 2048]--+
| .... o=..
| +.*o .... + |
| Bo+o. O.. |
| ... +e o |
| + S |
|.. |
|. |
| |
| |
+ ————— –+


Note: When prompted to enter passphrase, do not enter, because you would have wanted to play a password less once, if you set up a password to protect the private key, the login time or to lose the password, White did.



After this step, CD ~/.ssh, you can see the key pair you just generated, Id_rsa is the private key, Id_rsa.pub is the public key. The next step is to copy the public key to the target host.



Step Two: Copy the public key to the target host



Log in to the target host with SSH, then CD ~/.ssh directory, and if the directory does not exist, create your own mkdir-p ~/.ssh. Which account you will use to log in to the host, in which account in the home directory operation, if you want to avoid landing root, you have to go to/root under operation. Use ~ Better, don't think much.



With the. SSH directory, go in, and then pass the id_rsa.pub, you can use the SCP command, here to do a major operation, is to id_rsa.pub, the file content, write to a file called Authorized_keys, If the corresponding user name of the target host already has the. SSH directory and the Authorized_keys file, then you have to be careful about the operation, you may also have done a free login settings, this time you have to be careful not to put other people's settings to cover. If not, create a file touch ~/.ssh/authorized_keys, then execute the cat id_rsa.pub >> Authorized_keys and write your public key to Authorized_keys. Public key file. Pub contains only one line of information, and the above command is equivalent to appending that line of information to the last line of the Authorized_keys file.



If the. SSH directory is your host just created, then you may also need to change the permissions of this directory, the permissions are low, Chmod-r 0600 ~/.ssh, to this, all settings even if done, you can quit login, on their own host to try, and now after typing SSH command, You can log on to the host without a password.



How to implement SSH login to Linux host on Mac OS x


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.