If you must use a remote connection, due to the length of time it takes for some of the steps, it's highly recommended to run them inside a virtual console like TMUX or SCREEN.
It is recommended to perform the next steps local to the machine, and not via a remote connection.