generate public key
ssh-keygen
copy ssh public key to remote machine
ssh-copy-id -i <public-key-path> <remote ip/hostname>
sudo without password, log into the remote machine and run following command
sudo visudo
add ” <username> ALL=(ALL) NOPASSWD: ALL ” to the end of the file , replace <username> with your username