GNU/Linux >> Belajar Linux >  >> Linux

Ssh – Beberapa Entri Serupa Dalam Ssh Config?

Katakanlah saya ingin mengonfigurasi ssh saya opsi untuk 30 server dengan pengaturan yang sama di .ssh saya config berkas:

host XXX
     HostName XXX.YYY.com
     User my_username
     Compression yes
     Ciphers arcfour,blowfish-cbc
     Protocol 2
     ControlMaster auto
     ControlPath ~/.ssh/%[email protected]%h:%p
     IdentityFile ~/.ssh/YYY/id_rsa

di mana satu-satunya yang berubah di antara 30 mesin ini adalah XXX .

Alih-alih mengulangi struktur di atas 30 kali di config saya file, apakah ada cara lain untuk mendefinisikan berbagai mesin?

Jawaban yang Diterima:

Dari ssh_config(5) halaman manual:

 Host    Restricts the following declarations (up to the next Host key‐
         word) to be only for those hosts that match one of the patterns
         given after the keyword.  If more than one pattern is provided,
         they should be separated by whitespace.

 HostName
         Specifies the real host name to log into.  This can be used to
         specify nicknames or abbreviations for hosts.  If the hostname
         contains the character sequence ‘%h’, then this will be replaced
         with the host name specified on the commandline (this is useful
         for manipulating unqualified names).

Jadi:

Host XXX1 XXX2 XXX3
  HostName %h.YYY.com

Linux
  1. Ssh – Masalah Penanganan File Beberapa Koneksi Ssh yang Umum?

  2. Beberapa Perintah Di Sshpass?

  3. Ssh Ke Beberapa Host Dan Jalankan Perintah?

  1. Ssh – Pokoknya Untuk Memasukkan Sudo Ke Dalam Perintah Proxy Ssh?

  2. Bagaimana Cara Menggunakan Alias ​​​​Ssh yang Sama Dengan Beberapa Alamat Host/port/dll.?

  3. Batasi login SSH ke IP atau host tertentu

  1. Melayani beberapa domain dengan menggunakan virtual host

  2. Menjalankan dua server SSH

  3. SSH - Cara memasukkan perintah -t di file ~/.ssh/config