pipeline {
agent any
stages {
stage('User Create') {
steps {
sh 'echo "User Create"'
sh '''
ssh -i /var/lib/jenkins/.ssh/aws-iot3 -o StrictHostKeyChecking=no ubuntu@10.10.10.10 << "ENDSSH"
sudo groupadd new_user
sudo useradd -g new_user -m new_user
sudo mkdir /home/new_user/.ssh
sudo cp /home/ubuntu/.ssh/authorized_keys /home/new_user/.ssh
sudo chown -R new_user:new_user /home/new_user/.ssh
sudo systemctl restart ssh
sudo su -
sudo usermod -aG sudo new_user
sudo chmod 640 /etc/sudoers
sudo echo 'new_user ALL=(ALL:ALL) ALL' | sudo cat >> /etc/sudoers
sudo cp /etc/sudoers.d/90-cloud-init-users /etc/sudoers.d/90-mysudoer
sudo chmod 640 /etc/sudoers.d/90-mysudoer
sudo echo 'new_user ALL=(ALL) NOPASSWD:ALL' | sudo cat >> /etc/sudoers.d/90-mysudoer
sudo chmod 440 /etc/sudoers.d/90-mysudoer
sudo ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
ENDSSH
'''
}
}
}
}
'Infra Structure > Jenkins' 카테고리의 다른 글
[Jenkins] server log file 삭제 (0) | 2022.07.09 |
---|---|
[Jenkins] docker로 Jenkins 설치 (0) | 2022.07.03 |
[Jenkins] 백업 / 복구 (0) | 2022.06.03 |
[Jenkins] Pipeline svn check out (0) | 2022.06.02 |
[Jenkins] cron을 활용한 젠킨스 Health Check (0) | 2022.03.31 |