Linux Key Login

Source: Internet
Author: User

1. Generate the key.

The Ssh-keygen command is used to generate key pairs, basic options:

    • -t specifies the key type (RSA,RSA1,DSA,ECDSA).
    • -p Specifies the passphrase.
    • -f Specifies the name of the generated key file.
    • -C Add a comment.
  -T rsa-f key-p 123456   #创建文件名为key, the cipher is 123456, and the type is a key pair of RSA. A total of two files, where key is the private key, Key.pub is the public key.

2. Deploy the public key to Linux and download the private key to local.

cat key.pub >> ~/. ssh/authorized_keys  #如果没有. SSH directory, to be created first. (mkdir. SSH)
chmod ~/.ssh/authorized_keys #修改权限.

The download key can use the SZ command or the SCP command or the FileZilla software.

3. Modify the configuration file (/etc/ssh/sshd_config).

Open the following configuration.

Rsaauthentication Yes #开启密钥登录
Pubkeyauthentication Yes
Authorizedkeysfile. Ssh/authorized_keys #公钥存放地方

Permitrootlogin Yes # allows root login----to open according to actual needs
Passwordauthentication no #禁止密码登录----open according to actual needs

4. Restart the SSH service.

sudo service sshd restart

Note: If the SSH link fails, you can check the SSH log to find out why the link failed.

[Email protected] ~]# cd/var/log/ Less secure #用空格翻页, the last is the latest record.

Linux Key Login

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.