Is this the consequence of an SSH configuration of the server I'm trying to access?
Based on the details you shared, we can not be sure. You may even be connecting to two distinct, independently configured SSH daemons running on on the same system.
I mean, SSH can apply different login policy if I log [in] from localhost (in this case, the server) and if I log [in] from a remote machine (in this case, my PC)?
Yes, SSH servers can apply different policies based on various properties of the incoming connections.
For instance, the
Match keyword in OpenSSH
sshd's configuration allows you to define conditional blocks that group directives which are only applied (and override those previously set) if a list of specified conditions are met (see, for details,
man 5 sshd_config).
Adding this block to
/etc/ssh/sshd_config (the exact location may vary, depending on your system):
Match Address "!127.0.0.1,!::1,*"
- allow public key authentication by default;
- disallow public key authentication for connections coming from other addresses than
(Headache-saving note: as stated in
man 5 ssh_config, "PATTERNS",
[...] a negated match will never produce a positive result by itself. [...] The solution here is to include a term that will yield a positive match, such as a wildcard [...]
that is why
"!127.0.0.1,!::1,*" includes a
* at its end).