utorok 1. marca 2022

ssh check syntax from file

 If you create "ansible template sshd_config" for other servers. How to check if it is ok? 



1. basic sshd -t

We know command sshd with -t.


sshd -t check the configuration file. If it is ok we know empty output. If it is no ok sshd will inform us about syntax error.


This is an example: 


[root@localhost ~]# sshd -t

[root@localhost ~]# vi /etc/ssh/sshd_config

[root@localhost ~]# sshd -t

/etc/ssh/sshd_config: line 3: Bad configuration option: Precitaj_list

/etc/ssh/sshd_config: terminating, 1 bad configuration options


you see this mistake




2. sshd -t which control ansible template


I have created directory /etc/ansible/templates. In this templates are located configuration files for other servers. (/etc/hosts, /etc/ssh/sshd_config). 

I will write playbook which copy sshd_config to other servers via ansible. How check this configuration file? 

sshd -t -f

sshd -t -- check the configuration sshd_config

sshd -t -f - check the configuration sshd_config from different file


check this!

[root@localhost ~]# sshd -t -f /etc/ansible/templates/sshd_config
/etc/ansible/templates/sshd_config: line 4: Bad configuration option: bubli
/etc/ansible/templates/sshd_config: terminating, 1 bad configuration options
[root@localhost ~]# vi +4 /etc/ansible/templates/sshd_config


after repair: 

[root@localhost ~]# sshd -t -f /etc/ansible/templates/sshd_config
[root@localhost ~]#



Žiadne komentáre:

Zverejnenie komentára