Every Mac ships with an SSH server; it’s just switched off. Apple calls it Remote Login, and once it’s on you can open a shell on your Mac from another computer or copy files to it with SFTP.
System Settings > General > Sharing > Remote Login
Turn on Remote Login, then click the info button next to it. That’s where the settings that matter live. Under Allow access for, I’d pick Only these users and add just your own account, instead of All users. There’s also a switch called Allow full disk access for remote users. Leave it off unless you need to reach protected folders over SSH; you can always switch it on later.
The same pane shows the exact command to use, right below the Remote Login: On line. From another machine it looks like this:
ssh [email protected]
Use your short account name and the IP address or name of the Mac. With SFTP it works the same way, so a file manager or an sftp client can copy files over that same login.
Apple warns that allowing remote login can make your Mac less secure, and I agree with that. My advice: limit it to your own user, use SSH keys rather than a password where you can, and never forward port 22 on the router to it. To reach my MacBook from outside the house I’d use Tailscale, so the SSH port is never open to the internet. And switch Remote Login off again when you no longer need it.
Further reading: Allow a remote computer to access your Mac (Apple)