美文网首页
10. ubuntu sshkey登录

10. ubuntu sshkey登录

作者: _zt_d58b | 来源:发表于2020-03-23 14:34 被阅读0次
  1. 添加非root账号

    useradd testuser

2.生成sshkey

 ssh-keygen -t rsa

输入key密码
3.使用命令装公钥导入到VPS

必须: cat /home/testuser/.ssh/id_rsa.pub >> /home/testuser/.ssh/authorized_keys
4.配置/etc/ssh/ssh_config文件

 Host *

ForwardAgent no

# ForwardX11 no

# ForwardX11Trusted yes

# RhostsRSAAuthentication no

# RSAAuthentication yes

# PasswordAuthentication yes

# HostbasedAuthentication no

# GSSAPIAuthentication no

# GSSAPIDelegateCredentials no

# GSSAPIKeyExchange no

# GSSAPITrustDNS no

# BatchMode no

# CheckHostIP yes

# AddressFamily any

# ConnectTimeout 0

    StrictHostKeyChecking no

# IdentityFile ~/.ssh/identity

# IdentityFile ~/.ssh/id_rsa

# IdentityFile ~/.ssh/id_dsa

# Port 22

# Protocol 2,1

# Cipher 3des

# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc

# MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160

# EscapeChar ~

# Tunnel no

# TunnelDevice any:any

# PermitLocalCommand no

# VisualHostKey no

# ProxyCommand ssh -q -W %h:%p gateway.example.com

# RekeyLimit 1G 1h

    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes
    GSSAPIDelegateCredentials no

5.修改sshd_config
禁用密码登录 :PasswordAuthentication no
开启sshkey登录:PubkeyAuthentication yes
6.重启sshd ssh

systemctl restart sshd.service

7.ssh登录配置
用户名:testuser
密码:viomi2020
sshkey文件 id_rsa


image.png

相关文章

网友评论

      本文标题:10. ubuntu sshkey登录

      本文链接:https://www.haomeiwen.com/subject/fldwyhtx.html