0

I have a CentOS 8 server running in a vm. I access this server only via ssh. Therefore I dont need the login prompt once server finishes booting up. Therefore I went ahead disabling getty@.service.

Now server boots fine. I can ssh to the server.

My ask is, how can I clear the screen and display a custom text once server finishes booting. The contents from /etc/issues is not loaded as I assume this file is read and used by getty@.service? What options I have here?

BTR Naidu
  • 627
  • 1
  • 6
  • 13

1 Answers1

1

I recommend reading the man page of agetty(8). I have never tried this, but this should work: Enable the service again, copy the service file to /etc/systemd/system, and modify it to start /usr/sbin/nologin instead of /bin/login ...

Exempt from the manpage:

  -l, --login-program login_program
      Invoke the specified login_program instead of /bin/login.
      This allows the use of a non-standard login program. Such a
      program could, for example, ask for a dial-up password or use
      a different password file. See --login-options.

This way, the file /etc/issues is read and displayed, but a direct login on the terminal is not possible. You might want to change the line Restart=always to Restart=never, to prevent a restart loop, but after that, you should be good to go.

But keep in mind, that no matter how you disable the getty service - if you ever loose network connectivity on your server (for example due to a configuration mistake), you'll have to boot a rescue disc in order to recover your server... It might not be a good idea to disable the getty service!

Martin
  • 1,869
  • 6
  • 16
  • The article at this helped. https://raymii.org/s/tutorials/Run_software_on_tty1_console_instead_of_login_getty.html – BTR Naidu Jul 14 '22 at 14:37