728x90
🧷 Key-pair 생성
먼저, Key-pair를 생성한다.
ssh-keygen -q -N "" -f myvm.pem
🧷 이미지 복사
cp CentOS7-Base.qcow2 myvm.qcow2
🧷 이미지 커스터마이징 ⭐️
virt-customize -a myvm.qcow2 --install httpd,git,vim --firstboot-command 'systemctl enable httpd' --mkdir /root/.ssh --run-command 'chmod 700 /root/.ssh' --upload myvm.pem.pub:/root/.ssh/authorized_keys --run-command 'chmod 644 /root/.ssh/authorized_keys' --selinux-relabel
- 이미지 파일 이름 설정 : -a
-a myvm.qcow2
- 설치 : --install
--install httpd,vim
- 처음 부팅 시 실행할 명령어 : --firstboot-command
--firstboot-command 'systemctl enable httpd'
- 디렉터리 생성 : --mkdir
--mkdir /root/.ssh
- 부팅 시 자동으로 실행할 명령어 : --upload
--upload myvm.pem.pub:/root/.ssh/authorized_keys
- 파일 업로드 : --run-command
--run-command 'chmod 644 /root/.ssh/authorized_keys'
- SELinux 다시 설정 : --selinux-relabel
--selinux-relabel
🧷 가상머신 설치
virt-install --name myvm --vcpus 1 --ram 1024 --disk /shared/myvm.qcow2 --graphics vnc -v --import --noautoconsole
- 이미 생성된 디스크 이미지 사용하여 가상머신 생성 : --import
🧷 가상머신 ip 확인
virsh domifaddr myvm
🧷 원격접속
- 위에서 확인한 ip 주소로 ssh 접속
ssh -i myvm.pem [IP 주소]728x90
'Linux' 카테고리의 다른 글
| [Linux] 노드의 CPU 사용률 비교하기 (sar 명령어) (2) | 2024.01.08 |
|---|---|
| [Linux] 가상 네트워크 & 가상머신 생성 (0) | 2024.01.02 |
| [Linux] OpenStack으로 클라우드 환경 구성하기 (Ubuntu) (1) | 2023.12.20 |
| [Linux] OpenStack으로 클라우드 환경 구성하기 (CentOS7) (1) | 2023.12.20 |
| [Linux] 비대칭키로 사용자 인증하기 (PuTTygen) (4) | 2023.12.20 |