I've created an ec2 instance and a ssh-rsa keypair. I then try to connect with the instance using visual studio code remote-ssh extension. In the first try, it connects successfully. I can access files, create js files. I then wrote JS code, and while I'm writing code, after couple of minutes, ssh session gets disconnected abruptly.
[20:35:13.655] Log Level: 2
[20:35:13.677] [email protected]
[20:35:13.677] win32 x64
[20:35:13.689] SSH Resolver called for "ssh-remote+<my EC2 Ipv4 Address>", attempt 1
[20:35:13.690] SSH Resolver called for host: <my EC2 Ipv4 Address>
[20:35:13.691] Setting up SSH remote "<my EC2 Ipv4 Address>"
[20:35:13.888] Using commit id "fcac248b077b55bae4ba5bab613fd6e9156c2f0c" and quality "stable" for server
[20:35:13.895] Install and start server if needed
[20:35:13.944] Checking ssh with "ssh -V"
[20:35:16.339] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[20:35:16.414] Using SSH config file "C:\Users\abc\.ssh\config"
[20:35:16.415] Running script with connection command: ssh -T -D 65457 -F "C:\Users\abc\.ssh\config" 3.20.222.153 bash
[20:35:16.421] Terminal shell path: C:\Windows\System32\cmd.exe
[20:36:18.431] Resolver error: Error: Connecting with SSH timed out
at Function.Timeout (c:\Users\abc\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:1:130714)
at Timeout._onTimeout (c:\Users\abc\.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:105713)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
[20:36:18.439] ------
Then, whenever I try to connect the instance, it always throw ssh connection timed out error. Every single ssh client throws the connection timed out error after that sudden disconnection in the vscode session. It seems the instance stops responding to the incoming connection request.
I tried to create new instance, thinking maybe something went wrong in the instance. But again it happened. So it means its the problem from my side. I wonder why is it happening. How do I set up ec2 instance for remote development from my side over an ssh session?