ssh公钥私钥

时间:2021-02-18 14:49:04

ssh配置文件
vi /etc/ssh/sshd_config

putty下载
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

公钥加密,私钥解密

打开puTTYgen 点击genenrate 生成公钥
设置一下密码
点击save private key 保存私钥到电脑

把公钥保存到
mkdir /root/.ssh
cd .ssh/
vim authorized_keys

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAj/bc0eyjQea1/zse4XW3b18qPbmIiCsydTJDOxvrL1+aobTWVbNeGPCdpm+zuS1uQwcZOTg+VuPVkuX1slqkwK/RFDAzVMtlg6UMoZmB6kLLLi4MhhgBfH1xS+NUtx6s7NIDLkvohW37t/aigXf7i9HDSLZBgSEPgTAfpapvahbjr2DiVISdKN4RD3S+b4JYkiX/cP5U8B0Pcq3+OzUU6qF0zERzxjSTwE1rZeoRheayGsgXiHuFLBS1UF3uJS0mDMPxY7/DtGVQDjwFClnVkAAIrR6CCWfR1C/83N/yke5AtVU3pFm9JNhnWdCD+j+pgYm1FegjVFxSEVP2cgsHzQ== rsa-key-20150623

chmod 600 /root/.ssh/
chmod 700 /root/.ssh/authorized_keys

iptables -F 清除这些规则
service iptables save

getenforce 查看selinux的状态

vi /etc/selinux/config 进去改他的配置文件 永久设置他的状态

setenforce 0 临时生效

最后打开putty 加载私钥进来SSH->auth

ssh配置文件
vi /etc/ssh/sshd_config 加下面这行禁止密钥登陆
PermitRootLogin without-password

不要远程root用户登录
[root@localhost ~]# vi /etc/ssh/sshd_config
#LoginGraceTime 2m
PermitRootLogin no 修改这里
#StrictModes yes
[root@localhost ~]# service sshd restart = /etc/init.d/sshd restart