ssh服务

ssh服务:
SSH为Secure Shell的缩写, SSH 为建立在应用层和传输层基础上的安全协议。SSH是目前可靠的,专为远程登录会话和其他网络服务提供安全性的协议。常用于远程登录,以及用户之间进行资料拷贝。利用SSH协议可以有效防止远程管理过程中的信息泄露问题
修改ssh服务端口号
[root@mail ~]# vim /etc/ssh/sshd_config
port 2222
[root@mail ~]# systemctl stop firewalld
[root@mail ~]# setenforce 0
[root@mail ~]# systemctl restart sshd.service
这里写图片描述
拒绝root远程登录
[root@mail ~]# vim /etc/ssh/sshd_config
PermitRootLogin no
[root@mail ~]# systemctl restart sshd.service
这里写图片描述
允许特定用户登录
[root@mail ~]# vim /etc/ssh/sshd_config
AllowUsers zhangsan lisi
[root@mail ~]# systemctl restart sshd.service
这里写图片描述
这里写图片描述
Ssh互信,免登录配置
A端:
[root@mail ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory ‘/root/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:qRxBTMIXWDaC6PNJZ2iVbO70sfeN+m2qeZ+7mODhY4o root@mail.qq.com
The key’s randomart image is:
+—[RSA 2048]—-+
| . o+=O. |
|. . oXo. |
|. =.. |
| o + = o . |
| = * o S |
| o o = . |
| o .o. o |
| . oo+++o. |
| E .o**=+*o |
+—-[SHA256]—–+
[root@mail .ssh]# scp id_rsa.pub root@172.16.50.37:/root/.ssh
root@172.16.50.37’s password:
id_rsa.pub 100% 398 64.4KB/s 00:00
[root@mail .ssh]# ssh 172.16.50.37
Last login: Wed Aug 8 23:09:16 2018 from 172.16.50.60
B端
[root@mail ~]# mkdir .ssh
[root@mail .ssh]# mv id_rsa.pub authorized_keys
root@mail .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:u2PG+XG/FF+5i3fBA4exl/GLzOAteDl7Tk/ckV6OR3s root@mail.baidu.com
The key’s randomart image is:
+—[RSA 2048]—-+
| |
| . . |
| + +|
| . + ++|
| S o * B+=|
| o * =o@B|
| …o =.o*E|
| *. +.++o+|
| o.o. oo++.|
+—-[SHA256]—–+
[root@mail .ssh]# scp id_rsa.pub root@172.16.50.60:/root/.ssh/
root@172.16.50.60’s password:
id_rsa.pub 100% 401 236.1KB/s 00:00
A端
[root@mail .ssh]# mv id_rsa.pub authorized_keys
B端
[root@mail .ssh]# ssh 172.16.50.60
Last login: Thu Aug 9 11:35:48 2018 from 172.16.50.222
五:使用证书进行登陆
使用以下命令创建证书:
[root@web ~]# ssh-keygen -t rsa -b 4096
[root@web .ssh]# mv id_rsa.pub authorized_keys
然后将私钥下载到本地系统(桌面)
在windows系统上使用xshell创建新会话,使用公钥进行免密登陆
修改配置文件保存退出,重启服务

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值