How to allow connections to SQL Server only from localhost? I'm talking about SQL Server 2017 on a Linux machine.
Linux / Windows / OSX notwithstanding, this is not a PowerShell question, which is what we are here to help with. So, off topic for this Q&A forum. This is a specific SQL security / risk management one. Yet, not to send you away empty handed, connections are per user id configured in SQL, not the host the connection is coming from. This host level restriction is a network layer - host to host configuration topic. Yet, you really need to ask this question on a network / security and or SQL forum.