ssh

在这里插入图片描述
server端
yum install openssh-service -y 安装ssh包
useradd xiaoming 添加xiaoming,xiaohei俩个用户
useradd xiaohei
echo redhat | passwd --stdin xiaoming
echo redhat | passwd --stdin xiaohei
vim /etc/ssh/sshd_config
添加端口2000
在这里插入图片描述
在文件的最后一行(一定要在最后一行)添加白名单
allowusers xiaoming xiaohei
允许这俩个用户被登录
如果是拒绝root被远程登录:找到PermitRootLogin参数,修改
PermitRootLogin no
在这里插入图片描述
:wq
systemctl restart sshd
systemctl stop firewalld
setenforce 0

如果用户没有远程登录过,是没有.ssh 这个目录的
所以
su - xiaoming
ssh localhost
su - xiaohei
ssh localhost
这样会自动生成一个.ssh 目录

client端
yum install openssh-service
systemctl start sshd
systemctl stop firewalld
setenforce 0

useradd xiaoming
echo redhat | passwd --stdin xiaoming
su - xiaoming
ssh localhost

cd .ssh
ssh-keygan -t rsa 创建秘钥

秘钥密码
在这里插入图片描述
传公钥文件到服务端
.pub 后缀的为公钥文件

第一种方法:
ssh-copy-id xiaohei@192.168.30.129 -p 2000
传给ip地址为30.129的xiaohei用户,端口为2000
第二种方法:
scp -P 2000 11.pub xiaohei@192.168.30.129:/home/xiaohei/.ssh
传11.pub公钥文件给ip地址为30.129的xiaohei用户下的/home/xiaohei/.ssh目录,端口为2000,注意:-P 大写,scp这个命令要大写

秘钥默认在.ssh下,在这目录下才能被识别

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值