RSA Authentication login configuration for LINUX-SSH

Source: Internet
Author: User

First look at the experimental environment:

[[email protected]localhost  ~] # cat/proc/version  #ip 192.168.254.130  Linux version 2.6.32-431.el6.x86_64 ([ Email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (gcc)) #1 SMP Fri Nov 03:15:09 UTC 2013[[email&nb Sp;protected]wulaoer  ~]# cat/proc/version  #ip 192.168.254.131  Linux version 2.6.32-431.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)) #1 SMP Fri Nov 03:15:09 UTC 2013[email protected] ~$ sudo cat/proc/version  #192.168.254.129  [sudo] Wlof Password: Linux version 4.2.0-16-generic ([email protected]) (gcc version 5.2.1 20151003 (Ubuntu 5.2.1-21ubuntu2)) # 19-ubuntu SMP Thu Oct 8 15:35:06 UTC 

Two CentOS and one Ubuntu, two centos versions of the same, in order to distinguish me from each user in red to distinguish. If you are a newly installed system then you need to install Ssh,centos direct yum-y install SSH If it is Ubuntu, use sudo apt-get install openssh-server very simple, a command to execute on it.

First: Key generation

[Email protected] ~]# ssh-keygen-t rsagenerating public/private RSA key pair. Enter file in which to save the key (/ROOT/.SSH/ID_RSA): Created directory '/root/.ssh '. Enter passphrase (empty for no passphrase): Enter same passphrase Again:your identification have been saved in/root/.ssh/ Id_rsa.  #私钥文件Your public key has been saved in/root/.ssh/id_rsa.pub.  #公钥文件The key fingerprint is:8e:5f:78:ca:fc:79:cc:e0:c7:18:2a:31:2f:0a:8d:40 [email protected]the key ' s randomart image is:+--[RSA 2048]----+|                 | |                 | | E               | |.                | |       S        | |. o  oo. o      | |  O. . +ooob     | |   .  o+o+o.*    | |    .. o=.oo     |+-----------------+[[email protected] ~]# cd/root/.ssh/# If it is Ubuntu, it is under the name of the user under the home directory. SSH directory. [email protected]. ssh]# Lsid_rsa  id_rsa.pub

Second: You can modify the public key file name directly locally or in the process of transmission modification, this according to their own habits.

[email protected]. ssh]# ll total dosage 12-rw-------. 1 root root 1675 May  23:10 id_rsa-rw-r--r--. 1 root root  394 May  23:10 id_rsa.pub-rw-r--r--. 1 root root
   397 May  20:13 known_hosts[[email protected]. ssh]# mv id_rsa.pub Authorized_keys   #或者 [[email protected]. SSH ]# scp-r authorized_keys 192.168.254.130:/root/.ssh/[email protected] ' s Password:authorized_keys 100% 394 0.4KB/s 00:00

Third: Test direct login to see if you need to use a password.

[email protected]. ssh]# ssh 192.168.254.130Last Login:fri 00:28:12 from 192.168.254.131[[email protected]
   
    localhost
   

Note here that the hostname has been sent a change indicating that the login was successful.

A machine name Wulaoe and an ubuntu password-free login localhost,wulaoer has been set up, the following is set Ubuntu.

[Email protected]:~$ cd/home/wlof/.ssh/  #这里的wolf是我的用户名下的家目录 [email protected]:~/.ssh$ lsknown_hosts[email protected]:~/.ssh$ ssh-keygen-t RSA #如果这里要是加sudo的话认证的用户就是root了, to see the path of the authentication file generating public/private RSA key pair. Enter file in which to save the key (/HOME/WLOF/.SSH/ID_RSA): Enter passphrase (empty for no passphrase): Enter same PASSP Hrase again:your identification has been saved In/home/wlof/.ssh/id_rsa.   #私钥文件路径Your public key has been saved in/home/wlof/.ssh/id_rsa.pub. #公钥文件路径The key fingerprint is:sha256:fe+ob2mq4gfwwa4misx8bsttprbtczthwgkoua/g78a [email protected]the key ' s Randomart Image is:+---[RSA 2048]----+|. o*bx++. . ||. O.b+x O + | | .+ =.* = || =.. E o *. . || o+ o= S O. || O. . = O | | . . . || . || |+----[SHA256]-----+[email protected]:~/.ssh$ lsid_rsa id_rsa.pub known_hosts

SSH Verification Test

[Email protected]:~/.ssh$ scp-r id_rsa.pub [email protected]:/root/.ssh/authorized_keys  #在这里要注意必须要在连接的IP前加 [ Email protected], or the system will default to use the current user name, here has to add in the way added [email protected] ' s password:id_rsa.pub                            100%  407     0.4kb/ s   00:00    [email protected]:~/.ssh$ ssh 192.168.254.130[email protected] ' s password: [email protected]:~/.ssh$ SSH [email protected]last login:fri 00:28:44 from 192.168.254.131[[email protected] ~]#     #主机名已经切换过来, indicating successful login

One login multiple settings

  

  

  

RSA Authentication login configuration for LINUX-SSH

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.