Linux 创建用户角色并添加ssh登录权限

# 1 root权限下
useradd /home/xiaoli xiaoli
# 2
passwd xiaoli

# 3
cd /home  && mkdir xiaoli

# 4 
chown xiaoli xiaoli/

# 5 切到xiaoli的角色
su xiaoli

# 6
cd /home/xiaoli
# then 
mkdir .ssh
# then 
cd .ssh
# then 
vi authorized_keys
# 写入ssh public key 后
chmod 600 authorized_keys

# 7
su root
#then 
 vi /etc/ssh/sshd_config

# 写入(daxiong是原有的用户)

AllowUsers daxiong xiaoli

# 保存
/usr/sbin/sshd -T
#没错后
service sshd restart

注意:

1. ** 所有操作执行后必须验证能登录后才关闭原有窗口**

2. sshd_config文件中已写入:

PermitRootLogin no
PasswordAuthentication yes

表示无法使用root登录并使用密码登录,只能通过ssh key访问

常用命令:

查看 所有用户:

cat /etc/passwd

查看登录情况

lastlog
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值