OS 기술/Linux

리눅스(우분투) AD JOIN 스크립트 (08) - AD_CONNECT

DongT 2023. 3. 3. 15:01
728x90
반응형

아래 내용 파일로 붙여넣어서 실행하면 자동으로 AD 연결됨.

사전에 AD서버, 클라이언트서버(리눅스) 환경은 구성이 되어있어야함. (AD설정, 방화벽 등)

----------------------------------

 

#!/bin/sh

 

# Language English Setting

LANG=C

export LANG

 

# For each system Setting Args input

echo "=============================="

echo "Step1. Input AD INFO"

echo "=============================="

echo ""

echo "Domain name(e.g. testad.com) : "

read DOMAIN

echo "AD administrator name(e.g. Administrator) : "

read ADADMIN

echo "AD administrator password(e.g. p@ssw0rd) : "

read ADADMIN_PASS

 

sleep 1

echo ""

 

# AD Connectable Check

echo "=============================="

echo "Step2. AD Connect Check"

echo "=============================="

echo ""

sleep 1

realm discover $DOMAIN

echo ""

 

# AD Join

echo "=============================="

echo "Step3. AD Join"

echo "=============================="

echo ""

sleep 1

expect <<EOF

spawn realm join -U $ADADMIN $DOMAIN

expect "Password for $DOMAIN: "

send "$ADADMIN_PASS\r"

expect eof

EOF

echo ""

 

# AD Join Check

echo "=============================="

echo "Step4. AD Join Check"

echo "=============================="

echo ""

sleep 1

realm list

echo ""

728x90