1. add EPEL repository
yum -y install pam_radius
2. vi /etc/pam.d/sshd
auth required pam_radius_auth.so
3. mkdir /etc/raddb
vi /etc/raddb/server
your_radius_ip your_radius_secret 3
useradd username
on FreeRadius Server:
add this server to NAS table
add ssh username and password
Notes:
use ansible to add users:
yum -y install ansible openssh-clients
ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -C ‘‘ -N ‘‘
ssh-copy-id remote-ip-address
vi /etc/ansible/hosts
add single user:
ansible all -a "useradd username"
add multiple users:
vi /root/createuser.sh
#!/bin/bash
for username in username1 username2 username3; do
id $username > /dev/null 2>&1
if [ $? -gt 0 ]; then
useradd $username
fi
done
chmod +x /root/createuser.sh
ansible all -m script -a "/root/createuser.sh"
时间: 2024-11-07 04:21:40