I want create proxy SOCKS5 from AWS EC2 server. I'm use this guide: https://github.com/vifreefly/ec2_proxies My progress through the guide has come to the point where the script creates the server, adds SSH keys to AWS, then goes on to create the GOPROXIE server and at this point, something seems to go wrong.
aws_instance.ProxyNode[0]: Destroying... [id=i-0de2fc82d9c85cb74]
aws_instance.ProxyNode[0]: Still destroying... [id=i-0de2fc82d9c85cb74, 10s elapsed]
aws_instance.ProxyNode[0]: Still destroying... [id=i-0de2fc82d9c85cb74, 20s elapsed]
aws_instance.ProxyNode[0]: Still destroying... [id=i-0de2fc82d9c85cb74, 30s elapsed]
aws_instance.ProxyNode[0]: Still destroying... [id=i-0de2fc82d9c85cb74, 40s elapsed]
aws_instance.ProxyNode[0]: Destruction complete after 40s
aws_instance.ProxyNode[0]: Creating...
aws_instance.ProxyNode[0]: Still creating... [10s elapsed]
aws_instance.ProxyNode[0]: Provisioning with 'file'...
.....
aws_instance.ProxyNode[0]: Still creating... [5m10s elapsed]
Error: timeout - last error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [no public key], no supported methods remain
provider "aws" {
version = "~> 2.7"
access_key = "${var.AWS_ACCESS_KEY_ID}"
secret_key = "${var.AWS_SECRET_ACCESS_KEY}"
region = "${var.AWS_DEFAULT_REGION}"
}
resource "aws_security_group" "ec2_proxies_sg" {
name = "ec2_proxies_sg"
# Open up incoming ssh port
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
# Open up outbound internet access
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
# Open up incoming traffic for proxy
ingress {
from_port = "${var.PROXY_PORT}"
to_port = "${var.PROXY_PORT}"
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
# https://www.terraform.io/docs/providers/aws/r/key_pair.html
resource "aws_key_pair" "ec2_key" {
key_name = "${var.KEY_PAIR_NAME}"
public_key = "${file("${var.PUBLIC_KEY_PATH}")}"
}
resource "aws_instance" "ProxyNode" {
count = "${var.AWS_INSTANCES_COUNT}"
ami = "${var.AWS_INSTANCE_AMI}"
instance_type = "${var.AWS_INSTANCE_TYPE}"
key_name = "${aws_key_pair.ec2_key.key_name}"
vpc_security_group_ids = ["${aws_security_group.ec2_proxies_sg.id}"]
tags = {
Name = "Proxy Node ${count.index}"
}
provisioner "file" {
source = "setup.sh"
destination = "/home/${var.AWS_INSTANCE_USER_NAME}/setup.sh"
}
provisioner "remote-exec" {
inline = [
"chmod +x ./setup.sh",
"sudo ./setup.sh ${var.AWS_INSTANCE_USER_NAME} ${var.PROXY_TYPE} ${var.PROXY_PORT} ${var.PROXY_USER} ${var.PROXY_PASSWORD}",
]
}
connection {
type = "ssh"
host = self.public_ip
user = "${var.AWS_INSTANCE_USER_NAME}"
private_key = "${file("${var.PRIVATE_KEY_PATH}")}"
}
}
output "instances" {
value = "${aws_instance.ProxyNode.*.public_ip}"
}
I'm try change folder SSH key. Manual connect to AWS EC2 server and i'm connected manual with SSH key. Try change username to ec2-user and ubuntu and root.