Lightsail Django Instance access w/o SSH service running

0

Hi, thanks for this forum to ask questions.

I foolishly ran sudo service ssh restart after editing my /etc/ssh/sshd_config file on my instance, and have been struggling to gain access for a day now. Logging in with the browser Lightsail SSH route doesn't work, yields the Upstream_Not_Found error; the instance is "running"; I've attempted a launch script [ sudo service start ssh ; grep -v "-foolish lines I added to sshd file-" > newfile, mv newfile to sshd ] with a snapshot instance of the damaged instance, create the instance, wait 15 minutes, but same error as above.

I'm at a loss -- what can I do to gain access and fix those files?

I've also go through the tutorial provied by AWS for using the Systems Manager (https://repost.aws/knowledge-center/lightsail-resolve-ssh-console-errors) to use Run Command, but can't find my instance listed whenever I try to use it --- help!!!!! thanks!

gefragt vor 8 Monaten177 Aufrufe
2 Antworten
0

Hello.

Did you copy any files before modifying /etc/ssh/sshd_config?
If you have done so, I think you should write a startup script to restore the configuration file from the copy and restart sshd.
If you do not have a copy left, try running a startup script that edits the configuration file using a command such as "sed" to restore the configuration file to its original state.

profile picture
EXPERTE
beantwortet vor 8 Monaten
  • Thanks for the response! Unfortunately, I just tried this variation on my grep method, and still no go.

    Am I formatting the launch script correctly? I simply add my 1 line commands to the launch script dialog box when creating a new instance from a snapshot in the Lightsail browser portal. Does it need the bash shebang at the top? Should I use sudo for the command?

    I am willing to settle with simply accessing the files for copying purposes now, as I've created a new fresh instance and begun to migrate over: What options do I have to simply access the files if ssh is down on the system? < ---- any insight into this MUCH APPRECIATED! Thanks!

  • Hi again! Any follow up? Is there a way I can mount the snapshot/back-up I made of the instance so I can copy out the files I need? Thanks!

0

Have you considered making a snapshot of the instance, and then converting that into an EBS volume so that you can attach to another instance? This would let you view and edit the files, or clone them onto the new instance.

https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lightsail/create-disk-from-snapshot.html

AWS
MODERATOR
beantwortet vor 8 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen