- 添加非root賬號(hào) useradd testuser
2.生成sshkey
ssh-keygen -t rsa
輸入key密碼
3.使用命令裝公鑰導(dǎo)入到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