Use SSH connect to your Godaddy server. Then once you've done that cd
to whatever directory you want the files to be copied to. Next open an sftp session to your Hostgator account using the command:
sftp -P [port-number] <address-of-hostgator-server>
The port number is the port that you use when you SSH to the server normally. If you don't usually specify a port when connecting the default is 22.
From there you can download the files to the godaddy sever using the cd
command to find the files/directories you want and then the get
command on the file or directory you want to download them.
Note: This will not work if the Godaddy servers have a firewall rule blocking port 22 (or whatever port you use to connect to hostgator) outbound in which case you're out of luck, you'll need to download the files locally and then upload them again.
Some Theory
To copy files from one host to another you can't copy files from SSH by itself, you need to use something like sftp
or wget
. In this case sftp is the easiest option because it is already installed on whatever linux host you are using and if the target server has SSH enabled you can use it.
When you SSH from your computer that you are working on to the GoDaddy server, any commands you run inside of that SSH shell are now being run on that GoDaddy server. By using the sftp
command inside of this shell you create a connection between the GoDaddy server and the Hostgator server which you can control through the SSH shell you have open to GoDaddy. In essence you are using SSH to control the GoDaddy server which is using sftp to communicate with the Hostgator server.
Actually Doing It
To answer your example from the comments, you SSH to the GoDaddy server, then cd
to wherever you want to the new files to go. Then once you've done that open the connection to the hostgator server using the command you proposed.
sftp -P 2222 username@my_server_ip
Now your SSH prompt should change to an sftp>
prompt. This means that any commands you run now are commands for the sftp connection between the GoDaddy server and the Hostgator server. Now cd
to wherever the "test" directory is on the Hostgator server and use get -r test
to download that directory which will copy it to the GoDaddy server. Then type exit
into the sftp prompt returning you to the SSH prompt for the GoDaddy server where you will now find your files.