Rotten mud: Learning ssh key portable, ssh key

Source: Internet
Author: User
Tags ssh server

Rotten mud: Learning ssh key portable, ssh key

This article is written by Xiuyi Lin FengProviding friendship sponsorship, first launched in the dark world

In the previous article, "Learn ssh without password", we explained how to use an ssh key to log on to the server without a password.

This article explains how to carry generated keys with you.

For detailed steps on how to generate an ssh key, see the previous article "Learn ssh password-less login".

1. Generate a key

Now we use xshell to generate a key. Note: in this chapter, I will only proceed without further instructions.

As follows:

Now we have the public key and private key: and id_dsa_150518. Upload the Public Key to the ilanni user directory of the server to be connected. As follows:

Ifconfig eth0 | grep 'inet addr '| awk' {print $2} '| cut-d:-f2

Cat. ssh/authorized_keys

Now we can carry this key id_dsa_150518 with you, and connect to the server wherever you are.

Note: The key we are talking about now is actually the ssh Private Key generated by xshell above.

Note that the private key id_dsa_150518 can carry the private key file or copy the content of the private key to other files. As follows:

Note: The content of the ssh private key is being copied and cannot contain any character.

2. Connecting to the ssh server in windows

Assume that the OS we use is windows, and the ssh private key is around us. Then we can use this private key to connect to the ssh server.

Here, we will explain how to use xshell to connect to the ssh server. Of course, you can also use other ssh client software for connection.

Run the following command to connect to the ssh server:

Ssh ilanni@

In this case, the xshell window will pop up asking you to enter your password. As follows:

We do not select the Password option, but select the Public Key option. Then select Browse> file as follows:

Find the ssh private key file id_dsa_150518, as shown below:

Select the private key file as follows:

We can see that when we connect to the server, xshell does not prompt us to enter the password.

Note: The token is saved.

When connecting the sshserver to select a secret file, you only need to select the ilanni.txt file.

3. Connect to the ssh server in linux

In chapter 2, we explain how to connect to the ssh server through the ssh private key in windows. In this section, we will explain how to use the ssh private key to connect to the ssh server in linux.

First, upload the ssh Private Key to the linux host or create any new file on the linux host, copy the content of the Private Key to the file, and then use the following command to connect:

The ssh-I id_dsa_150518 ilanni@

We can see that you still need to enter the user password to connect to the ssh server

Is our operation incorrect or what is going on?

If you carefully read the above prompt, you will find that this is because the ssh private key user permission is too large to be set and is not secure.

SshFor the sake of security, the permission on the private key file is generally set to 600, that is, the user has read and write permissions on the private key file, the user group and other user groups do not have any permissions on the private key file.

Now we only need to set the ssh Private Key File Permission to 600, as shown below:

Chmod 600 id_dsa_150518

Connect again using the ssh-I id_dsa_150518 ilanni@ Command, as shown below:

We can see that we have already entered the server without a password.

Note: The-I parameter in the preceding command is used to specify the ssh private key file.

For more information about how to use ssh commands, see the help of ssh. As follows:

Ssh -- help

All the content about the ssh key is complete.

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: 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.