0

I tried to use SFTP using sudo to make changes in a file, following instruction:

Adding this line was a fix for me and comment the existing subsystem line:

  1. /etc/ssh/sshd_config:
    Subsystem sftp sudo -n true && sudo -n /usr/lib/openssh/sftp-server || /usr/lib/openssh/sftp-server
    
  2. sudo systemctl restart sshd
    

Now, I can't connect to the server at all, not via SFTP or SSH, and want to revert the change to be able to connect via SSH; how can I do this?

1 Answers1

1
  1. Find another way to connect to the server that is not SSH.

    • If it has a remote management agent running (such as Salt-Minion): Use it to remotely run commands on the server.

    • If it's a virtual machine: Use the 'remote console' access provided by the VM host to log in as if using a local terminal. (Most competent 'cloud' hosts have this feature; look for "console" or "noVNC" or "Lish", etc.)

    • If it's a physical server: Connect to its console through the 'remote KVM' feature if it has one.

      Physical servers have a management controller (IPMI/iLO/iDRAC/AMT/vPro); dedicated-server hosting companies often provide remote console access under various names (e.g. "KVM Console" in Hetzner Robot).

      (Some hosting companies, such as OVH, don't offer remote console for dedicated servers but do offer net-boot into a rescue ISO.)

    • If it's a physical server without remote console: Walk/drive to it and log in at the console, or find a person who can do that for you.

  2. Look at the system logs to find out why your change failed.

  3. Edit the file to undo your changes, then restart sshd.

grawity
  • 501,077