I’ve set domain for my server using dns service and I was wondering if I can ssh with that domain. Can I do that? (and also ho do I do it?)
you have to setup access for ssh from the outside.
This is not related to Nextcloud and off-topic.
The internet will help you, please add your question to your preferred search engine.
You can. You will have to set up a port forward on your router to forward the ssh port to your nextcloud.
Also, be aware that opening console access to your server to the internet is a significant security hazard. Consider using key-based authentication (or just not doing it).
If you need remote access to the system, a VPN is a safer and more flexible method.