I only want to display this message for password authentications, and not when keys are used. It should only show to a user who is logging into a host, and not when they are sshing from one host to another (our hosts all have keys set up so we can ssh from one to another without entering passwords).
Você está falando sobre as chaves usuário ~/.ssh/authorized_keys ou host chaves /etc/ssh/ssh_known_hosts ?
Currently, I have a line for Banner in the /etc/ssh/sshd_config file which points to a text file containing the warning message.
Banner é exibido antes de qualquer autenticação.
I'm wondering if there is a way to do this with pam or some other mechanism?
Você pode tentar verificar o nome do host remoto (origem): verifique com pam_access se o usuário vier de fora da sua rede:
session [success=1 default=ignore] pam_access.so accessfile=/etc/pam_access_localnet.conf
session optional pam_echo.so file=/etc/notice
/etc/pam_access_localnet.conf :
+ : ALL : 192.168.201.0/24
- : ALL : ALL