简体   繁体   中英

SSH into Windows Server Ec2 using Terraform

I'm trying to set up terraform to automate the process of spinning up an Windows EC2 instance and using SSH to access the instance automatically. I can get it to work on a Linux server and saw Windows add OpenSSH to Windows Server 2019. Can anyone advice me on a way to do this please?

To ssh in your EC2 instance, you have to provide user and private key. In Terraform you can use connection keyword to ssh in EC2 instance. For Windows, you need to renaming yourkey.pem to "id_rsa"

connection {
    type     = "ssh"
    user     = "ec2-user"
    private_key = file("C:/yourpath/id_rsa")
    host     = aws_instance.web.public_ip
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM