Moving Website from One Server to Another using SSH

I was tasked to migrate an existing website from one web hosting server to another using SSH. At first, I was not aware of this, that I had to download everything to my local machine and upload the downloaded files to the new web hosting server. This method sucks, time consuming, and too much hassle. Luckily, I have found a code that worked.

Using an SSH program, I used Putty on this one, connect to the web server you’re transferring your files into. Be sure your web hosting provider allows you to have Shell Access, otherwise, you won’t be allowed to use SSH.

Login as your username. If you’re using cPanel, then login your cPanel username.

It will prompt for your password, so enter your cPanel password.

Once you successfully logged into your SSH, please input the code below with correct values.

scp username@host:folder/to/file destination/

Change username to the SSH username of your CURRENT server, it’s SSH host for example, Folder/to/file is the file you want to transfer to your new account, and destination is where you want that file to reside on.

Be sure to compress the files/folders to .tar.gz, as you cannot move a folder using the code below.

Here’s an example: scp public_html

Once that is complete, you can go check the destination folder, if the file was transferred. If the file is there, just extract the file, and you’re done! Bravo. If you have questions/reactions etc, just drop a comment below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.