zoukankan      html  css  js  c++  java
  • linux新增用户,然后配置密钥验证

    建新用户

    adduser hadoop
    
    

    用户创建后切换用户su hadoop

    生成密钥

    切换后执行ssh-keygen -t rsa生成密钥

    [hadoop@localhost ~]$ ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/hadoop/.ssh/id_rsa): 
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /home/hadoop/.ssh/id_rsa.
    Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.
    The key fingerprint is:
    79:0a:3d:04:3d:83:d5:24:a8:94:62:89:f3:b7:90:f8 hadoop@172.31.10.94
    The key's randomart image is:
    +--[ RSA 2048]----+
    | . . ..=oo.      |
    |o + o o.+..      |
    | = + .  .o       |
    |. + o  o .       |
    | . o .. S .      |
    |  E .  . +       |
    |        .        |
    |                 |
    |                 |
    +-----------------+
    

    然后把id_rsa.pub的改名成authorized_keys. id_rsa.pub里的内容最后会有 hadoop@localhost,转成authorized_keys的时候如果不能登录,就把最后这节删掉.
    当有多个公钥时,在authorized_keys里追加写就行了.另外要保证authorized_keys的权限是600,.ssh的权限是700

    chmod 600 authorized_keys
    chmod 700 .ssh
    

    也可以用xshell生成密钥,然后将公钥上传到服务器,写入authorized_keys里.

    ssh命令登录远程机

    ssh -i ~/.ssh/<private_key_file> <username>@ip

  • 相关阅读:
    利用Github Actions自动保持 GitHub 提交状态常绿
    windows下搭建轻量级php代码审计环境
    jquery实现点击弹出对话框
    redis学习记录(1)Redis简介
    StatefulSet
    Pod
    Spark 写Hive指定动态分区
    我常用的git操作
    在C#中如何使用GetOpenFileName函数多选文件
    image matching challenge
  • 原文地址:https://www.cnblogs.com/saias/p/6973239.html
Copyright © 2011-2022 走看看