4

I have created AWS lightsail instance for learning purposes. I downloaded the key file and created a public key with it and store it in the .ssh/authorized_keys file.

For the testing, I tried to connect with ssh via my terminal. It was connected and worked fine and I closed the connection and reboot the server.

After reboot the server I tried to connect again with a key file from my terminal and I was not able to log in. I logged in to the AWS console and try to connect from that end and, it was giving me an empty black screen window.

Any suggestions?

Yash
  • 482
  • 4
  • 12
  • How did you "reboot" the server? If it actually stopped and then started, it might now have a different public IP address. – John Rotenstein Feb 22 '21 at 10:31
  • From the AWS console, I selected reboot for the first time. but It didn't work and again I did stop and start. But same thing. When I create the Lightsail instance I created a static public IP address. So it is the same. – Yash Feb 22 '21 at 15:40
  • Check the Security Group associated with the instance to confirm that it is allowing Inbound traffic on port 22 from your IP address. Otherwise, it sounds like something it messed-up on the instance. If there was nothing important on it, it could be simpler to just delete it and launch a new Lightsail instance. – John Rotenstein Feb 22 '21 at 22:34
  • @JohnRotenstein I created an instance 3 times and having the same problem. But I will check with a firewall for port 22. – Yash Feb 22 '21 at 22:35
  • You said that you copied a key into the `authorized_keys` file, which suggests that you were able to successfully connect to the instance prior to making the change. Thus, it sounds like the problem is due to whatever you are changing. This is especially the case if you have done this 3 times and had the same problem 3 times. Or, were you not able to login to the instances to start with? More details, please. – John Rotenstein Feb 22 '21 at 22:39
  • Yes, I copied key into authorized_keys file and I got connected for the first time. Everything running fine. for the First time, I created root user, installed JDK and installed Tomcat Server and allow access of 8080 port with ufw. After that I closed the connection with ssh and reboot the server. But after reboot I was not able to connect with ssh and when I connected from was console there was only an empty black window opened. I did second time the same thing. It happened again. for the third time I just added my key and activate the firewall with ufw command. Same thing happened. – Yash Feb 22 '21 at 22:44
  • Sounds like it might be related to ufw. – John Rotenstein Feb 22 '21 at 23:01
  • @MuhammedAydogan Yes, sure! I mistakenly entered to the root account and store my public key into the authorized_keys file. what you have to do is, open the authorized_keys by the default user ("ubuntu", for this case) and then store your public key. I hope this helps! – Yash Mar 07 '22 at 21:47
  • In my case the problem was opening ufw without allowing ssh port . Anyways, thanks @Yash – Muhammed Aydogan Mar 09 '22 at 05:17

0 Answers0