Tramp can be used to edit remote files. Use the following command:
C-x C-f /[method:user@]remotehost:filename RET
C-x C-f /sudo::/path/to/file
C-x C-f /ssh:remotehost|sudo:user@remotehost: RET
M-x tramp-cleanup-all-connections
M-x tramp-cleanup-all-buffers
See tramp documentation.