• Ubuntu服务器开启密钥登录


    1.使用SecureCRT创建私钥和公钥.

    SecureCRT: Quick Connect -> Authentiation -> Public Key -> Properties -> Create Identity File -> DSA/RSA -> Set Passphrase -> Done

    这个时候在指定目录会生成两个文件,例如,私钥Identity和公钥Identity.pub

    2.创建一个新用户

    #useradd subsir -m
    #su subsir //切换到subsir用户,以下的操作必须用subsir账号操作,subsir必须有权限

    3.在/home/roger目录下创建.ssh文件夹并更改权限

    # mkdir /home/subsir/.ssh
    # chmod 700 /home/subsir/.ssh

    4.将公钥 Identity.pub 传到linux服务器,将SSH2兼容格式的公钥转换成为Openssh兼容格式

    # ssh-keygen -i -f Identity.pub >> /home/subsir/.ssh/authorized_keys
    # chmod 600 /home/subsir/.ssh/authorized_keys

    5.在SecureCRT里面设置登录模式为PublicKey,并选择刚刚创建的Identity文件作为私钥

    6.重启Ubuntu服务器上SSH服务器

    #sudo /etc/init.d/ssh restart

    7.由于已经设置了密钥登录,原来的密码登录就完全可以去掉

    # vi /etc/ssh/sshd_config

    #假如要修改端口:
    #修改port 22 为 port 端口号

    Protocol 2 /仅允许使用SSH2
    PubkeyAuthentication yes /*启用PublicKey认证
    PasswordAuthentication no /*禁止密码验证登录

    重启实例

    用的阿里云服务器,如果直接连接,会报下面错误:

    $ ssh root@47.94.132.115
    Permission denied (publickey).
    

    创建服务器的时候,连接秘钥会生成并下载到本地(xishuai-key.pem),解决方式:

    $ chmod  600 /users/xishuai/.ssh/xishuai-key.pem
    $ ssh -i /users/xishuai/.ssh/xishuai-key.pem root@47.94.132.115
  • 相关阅读:
    树链剖分
    后缀自动机
    莫队算法。
    线性递推BM模板
    笛卡尔积
    2019牛客暑期多校训练营(第三场) J LRU management 模拟链表操作
    线性基
    bitset 位运算
    Lindström–Gessel–Viennot lemma定理 行列式板子
    三角形
  • 原文地址:https://www.cnblogs.com/Gbeniot/p/12893795.html
Copyright © 2020-2023  润新知