zoukankan      html  css  js  c++  java
  • ssh否password登陆server

    在线辅导课非常多,但仍录,使用时方便日后查询。

    两server,内联网ip每间:

    172.16.3.91 (本地计算机)

    172.16.3.92 (远程机)

    现在想在本地计算机上通过ssh 172.16.3.92到远程机而不须要password。


    1.在本地机上用ssh-keygen 创建公钥私钥。

    [root@rs-1 ~]# ssh-keygen -t rsa

    Generating public/private rsa key pair.

    Enter file in which to save the key (/root/.ssh/id_rsa): 

    Enter passphrase (empty for no passphrase): 

    Enter same passphrase again: 

    Your identification has been saved in /root/.ssh/id_rsa.

    Your public key has been saved in /root/.ssh/id_rsa.pub.

    The key fingerprint is:

    dc:fc:ea:b8:bb:74:d7:75:4b:6a:27:82:28:27:be:d6 root@rs-1


    这个过程会提示输入password,记住直接按回车即可。不要输入password!要是输入了password,一会訪问的时候就须要输入password了。

    创建之后能看到例如以下两个文件

    [root@rs-1 .ssh]# ll

    total 24

    -rw------- 1 root root 1675 May  8 07:18 id_rsa

    -rw-r--r-- 1 root root  391 May  8 07:18 id_rsa.pub


    id_rsa是私钥

    id_rsa.pub是公钥。 主要给远程机使用的


    2.把公钥传到远程机上去。

    [root@rs-1 .ssh]# scp id_rsa.pub root@172.16.3.92:~/.ssh/authorized_keys

    Address 172.16.3.92 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!

    root@172.16.3.92's password: 

    id_rsa.pub                                                                                                                                  100%  391     0.4KB/s   00:00    


    3.ssh链接时候就不须要password了,直接登陆到远程机

    [root@rs-1 .ssh]# ssh 172.16.3.92

    Address 172.16.3.92 maps to localhost, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!

    Last login: Thu May  8 07:19:28 2014 from 172.16.3.91

    [root@rs-2 ~]# 




    參考:http://blog.csdn.net/gongqingkui/article/details/9023439

    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    51NOD 1069 Nim游戏
    51NOD 1066 Bash游戏
    51NOD 1058 N的阶乘的长度
    51NOD 1057 N的阶乘
    51NOD 1027 大数乘法
    RMQ 区间最大值 最小值查询
    Codeforces Round #426 (Div. 2) C. The Meaningless Game
    51NOD 1046 A^B Mod C
    OJ上 编译器 G++和C++的区别
    二分暑假专题 训练记录 2017-7-29
  • 原文地址:https://www.cnblogs.com/blfshiye/p/4840924.html
Copyright © 2011-2022 走看看