zoukankan      html  css  js  c++  java
  • Mac 使用 SSH 免密连接服务器

    1、生成 SSH 秘钥

    ssh-keygen -t rsa  生成的密钥对 id_rsa 和 id_rsa.pub,默认存储在 ~/.ssh 目录,其中没有后缀的是私有,有后缀 .pub 的为公钥。生成的时候要求输入密码,直接回车跳过,否则登录的时候又要输入密码,就违背了免密的初衷。

    2、在服务器上创建 .ssh 目录

    这个 .ssh 目录需要根据登录用户创建到用户的 home 目录中,如 root 用户就是 /root 目录下,tirion 用户就是 /home/tirion 下。

    3、使用 ftp 上传公钥(即 id_rsa.pub 文件)到服务器上刚才创建的 .ssh 中

    4、复制公钥:

    cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys  创建 authorized_keys 文件。

    5、修改 authorized_keys 权限:

    chmod 644 ~/.ssh/authorized_keys  必须为 644 权限

    6、编辑本地 config 文件:

    vi ~/.ssh/config

    内容如下:分别为别名,服务器地址,端口,连接的用户名,密钥路径

    Host Tirion
    HostName 45.xx.214.xxx
    Port 22
    User root
    IdentityFile ~/.ssh/id_rsa

    7、连接服务器:

    由于设置了别名为 Tirion,只需要使用 ssh Tirion 即可免密连接服务器了。

  • 相关阅读:
    R并行计算
    VMware虚拟机安装linux系统
    爬虫资料
    R-shiny服务器安装及配置
    数模国赛——致病基因
    vs 2013远程调试
    获取url的hash值
    JavaScript调试技巧之console.log()详解
    无法打开登录所请求的数据库
    location.host 与 location.hostname 的区别
  • 原文地址:https://www.cnblogs.com/3body/p/6178942.html
Copyright © 2011-2022 走看看