Connect to a remote server over emacs and tramp
Official docs - https://wikemacs.org/wiki/TRAMP
If you need to edit files as sudo - info how is in the docs above.
First of all, try to connect to the remote machine over shell, eshell or vterm like so:
ssh username@remotehost
You will get prompted for a password. Enter it and you should be able to connect.
Then open emacs and then let's try to open a file remotely, use the C-x C-f
/ssh:username@remotehost: # now you will get prompted for a password (don't forget : at the end of the remotehost name!!)
.authinfo
in your home dir will contain your credentials.
tramp
file in your .emacs.d
will contain your connection history.