Vagrant는 VM을 생성할 때 자동으로 SSH 설정까지 다 해줍니다.
접속하는 방법은 크게 3가지예요.
vagrant ssh (가장 간단한 방법)vagrant ssh
💡 장점: SSH 키, IP 주소 신경 쓸 필요 없음
💡 단점: 해당 디렉토리 안에서만 가능
vagrant ssh-config
출력 예시 👇
Host default
HostName 127.0.0.1
User vagrant
Port 2222
IdentityFile C:/Users/user/.vagrant.d/insecure_private_key
StrictHostKeyChecking no
PasswordAuthentication no
이 정보를 이용해 수동으로 SSH 접속할 수도 있습니다:
ssh -p 2222 [email protected] -i ~/.vagrant.d/insecure_private_key
💡 이렇게 하면 vagrant ssh 없이도 어디서든 접속 가능
만약 Vagrantfile에서 private_network를 설정했다면, 고정 IP로도 접속 가능: