简体   繁体   中英

Is there a way in python to RDP into a windows ec2 instance?

Like we have python library BOTO3 which we can use to ssh into a linux based ec2 instance, but it looks like the same script does not work for a windows based ec2 instance. I used the python script in this question to connect to my windows How to SSH and run commands in EC2 using boto3? . But I am getting the below error:

[WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

All my security group rules are compliant, I have RDP port open in incoming tab. Still getting this error. Is there a way in python to RDP into a windows ec2 instance? Or any other programing language for that matter?

To summarize what we talked about in the comments.

Your goal is to run SQL scripts against a database from an EC2 windows instance and you want to trigger this via Python.

Your suggested solution of using RDP is problematic, because in contrast to SSH, RDP is a GUI-driven protocol, it will essentially send color values for pixels to you, which is hard to interact with. The equivalent to an SSH connection is more or less PowerShell Remoting, which would require you to open a port, that is accessible from your python script.

A solution that doesn't require making the server accessible from the outside would be using Systems Manager automation. You can create an automation document to run a PowerShell script on the instance for example and trigger that via the API ( ssm:StartAutomationExecution ).

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