GNU/Linux >> Linux Esercitazione >  >> Linux

Abilita manualmente gli aggiornamenti automatici sui server cloud pubblici Red Hat Enterprise Linux e CentOS

Mantenere aggiornati i server con correzioni di sicurezza può aiutarti a evitare compromissioni del server. Sebbene gli aggiornamenti dei pacchetti non possano impedire tutte le violazioni della sicurezza, mantenere aggiornati i server dovrebbe essere una componente chiave delle tue procedure di sicurezza.

Questo articolo descrive come abilitare gli aggiornamenti automatici sui server cloud pubblici Red Hat®Enterprise Linux® (RHEL) e CentOS® Rackspace per garantire che gli aggiornamenti cruciali siano installati e aggiornati.

RHEL 6 e CentOS 6

Utilizzare i seguenti passaggi per abilitare gli aggiornamenti automatici sui server cloud pubblici RHEL 6 e CentOS 6 Rackspace:

  1. Dopo esserti connesso al tuo server, installa yum-cron eseguendo il seguente comando:

    $ yum -y install yum-cron
    
  2. Per visualizzare il yum-cron file di configurazione, utilizzare il comando seguente:

    $ vi /etc/sysconfig/yum-cron
    

    Puoi anche aprire il file in qualsiasi editor di testo.

    Per impostazione predefinita, la configurazione è impostata per scaricare e installare gli aggiornamenti, come mostrato nell'esempio seguente:

    # Pass any given parameter to yum, as run in all the scripts invoked
    # by this package.  Be aware that this is global, and yum is invoked in
    # several modes by these scripts for which your own parameter might not
    # be appropriate
    YUM_PARAMETER=
    
    # Don't install, just check (valid: yes|no)
    CHECK_ONLY=no
    
    # Check to see if you can reach the repos before updating (valid: yes|no)
    CHECK_FIRST=no
    
    # Don't install, just check and download (valid: yes|no)
    # Implies CHECK_ONLY=yes (gotta check first to see what to download)
    DOWNLOAD_ONLY=no
    
  3. (Facoltativo) Per impostare le notifiche per gli aggiornamenti automatici dei pacchetti, come l'ora dell'installazione, i pacchetti installati e gli errori di installazione, modifica la riga che inizia con MAILTO= per aggiungere un indirizzo email per ricevere le notifiche, come mostrato nell'esempio seguente:

    # if MAILTO is set and the mail command is available, the mail command
    # is used to deliver yum output
    
    # by default MAILTO is unset, so crond mails the output by itself
    # example:  MAILTO=root
    [email protected]
    
  4. Salva il file.

    Se stai usando vim per modificare il file di configurazione, premi esc e poi inserisci :wq per salvare eventuali modifiche.

    Dopo aver salvato il file, viene visualizzato il seguente messaggio che indica che il file è stato scritto correttamente:

    APT::Periodic::Update-Package_Lists "1";
    APT::Periodic::Download-Upgradable-Packages "1";
    APT::Periodic::Unattended-Upgrade "1";
    APT::Periodic::AutocleanInterval "14";
    
  5. Avvia il yum-cron servizio eseguendo il comando seguente:

    $ /etc/inid.d/yum-cron start
    
  6. Per avviare automaticamente il servizio al riavvio del server, eseguire il comando seguente:

    $ chkconfig yum-cron on
    

RHEL 7 e CentOS 7

Utilizzare i seguenti passaggi per abilitare gli aggiornamenti automatici sui server cloud pubblici RHEL 7 e CentOS 7 Rackspace:

  1. Dopo esserti connesso al tuo server RHEL 7 o CentOS 7, installa yum-cron eseguendo il comando seguente:

    $ yum -y install yum-cron
    
  2. Per visualizzare il yum-cron file di configurazione, utilizzare il comando seguente:

    $ vi /etc/sysconfig/yum-cron
    

    Puoi anche aprire il file in qualsiasi editor di testo.

    Per impostazione predefinita, gli aggiornamenti vengono scaricati automaticamente, ma non installati, come mostrato nell'esempio seguente:

    # Whether a message should be emitted when updates are available,
    # were downloaded, or applied.
    update_messages = yes
    
    # Whether updates should be downloaded when they are available.
    download_updates = yes
    
    # Whether updates should be applied when they are available. Note
    # that download_updates must also be yes for the update to be applied.
    apply_updates = no
    
    # Maximum amount of time to randomly sleep, in minutes.  The program
    # will sleep for a random amount of time between 0 and random_sleep
    # minutes before running.  This is useful for e.g. staggering the
    # times that multiple systems will access update servers.  If
    # random_sleep is 0 or negative, the program will run immediately.
    # 6x60 = 360
    random_sleep = 360
    
  3. Per scaricare e installare gli aggiornamenti automatici, assicurati che download_updates e apply_updates sono impostati su yes .

  4. (Facoltativo) Puoi impostare le notifiche nel file di configurazione in modo che l'output di yum aggiornamenti ti viene inviato via email per informarti di ciò che è stato completato e, in caso di problemi, di ciò che non è riuscito. Modifica le seguenti sezioni:

    1. Nel [emitters] sezione del file di configurazione, assicurati cheemit_via è impostato su stdio , come mostrato nell'esempio seguente:

      [emitters]
      # Name to use for this system in messages that are emitted.  If
      # system_name is None, the hostname will be used.
      system_name = None
      
      # How to send messages.  Valid options are stdio and email.  If
      # emit_via includes stdio, messages will be sent to stdout; this is useful
      # to have cron send the messages.  If email_via includes email, this
      # program will send email itself according to the configured options.
      # If emit_via is None or left blank, no message will be sent.
      emit_via = stdio
      
    2. Nel [email] sezione del file di configurazione, modificare il email_to campo per aggiungere l'indirizzo email a cui si desidera inviare l'output, come mostrato nell'esempio seguente:

      [email]
      # The address to send email messages from.
      # NOTE: 'localhost' will be replaced with the value of system_name.
      email_from = root@localhost
      
      # List of addresses to send messages to.
      email_to = [email protected]
      
      # Name of the host to connect to to send email messages.
      email_host = localhost
      
  5. Salva il file.

    Se stai usando vim per modificare il file di configurazione, premi esc e poi inserisci :wq per salvare eventuali modifiche.

    Dopo aver salvato il file, viene visualizzato il seguente messaggio che indica che il file è stato scritto correttamente:

    "/etc/yum/yum-cron.conf" 81L, 2620C written
    
  6. Controlla se il yum-cron il servizio viene avviato eseguendo il seguente comando:

    $ systemctl status yum-cron
    

    Se il servizio non è in esecuzione (inattivo), avvialo eseguendo il comando seguente:

    $ systemctl start yum-cron
    
  7. Ora che il servizio è in esecuzione, dovresti assicurarti che il servizio si avvii automaticamente dopo il riavvio del server. Esegui il comando seguente per verificare se yum-cron è abilitato:

    $ systemctl list-unit-files –type=service
    

    Trova il yum-cron.service processo nell'elenco. Se è abilitato, il servizio si avvia all'avvio del server. Se è disabilitato, usa il seguente comando per abilitarlo:

    $ systemctl enable yum-cron
    

Linux
  1. Registra Red Hat Enterprise Linux e allega un abbonamento ad Ansible

  2. Configurazione di un indirizzo IPv6 in Red Hat Enterprise Linux 7 e 8

  3. Creazione di un'immagine Red Hat Enterprise Linux 7 personalizzata per Microsoft Azure

  4. Aspetti da considerare quando si esegue Red Hat Enterprise Linux su Azure

  5. Modifica la porta SSH in CentOS e Red Hat

RHEL 6 – Guida all'installazione del server Red Hat Enterprise Linux passo dopo passo

Red Hat Enterprise Linux (RHEL) 8 passaggi di installazione con schermate

Come installare ONLYOFFICE su Red Hat Linux (RHEL) e CentOS

Come installare xrdp su CentOS 8 / Red Hat Enterprise Linux 8

7 modi per impostare il tuo nome host in Fedora, CentOS o Red Hat Enterprise Linux

Abilita manualmente gli aggiornamenti automatici sui server cloud pubblici Debian e Ubuntu 14.04 e 16.04