Copy a disk over SSH

Linode Staff

I am trying to save a backup of the disk in my local machine and I am experiencing a few issues.

I am running a CentOS 7, I am in Rescue Mode, and using the command

ssh root@12.34.56.78:35000 "dd if=/dev/sda " | dd of=/home/archive/linode.img

I am getting two errors:

dd: failed to open /home/archive/linode.img

I assumed that this error was caused by not having a file called linode.img yet, although I had already created the folder /home/archive.

ssh: could not resolve the hostname 12.34.56.78:35000 name or service unknown

I can ping this IP address and telnet on port 35000.

1 Reply

It shouldn't be necessary to create the linode.img file first, as the file should be created automatically if it is not found when the dd command runs. This may be a permissions issue. To check, you can run ls -l /home, and ensure that your user has the correct permissions to access the folder. It's also worth noting to pay close attention to what directory you are in when running a command. For example, if you are not specifying the full path for linode.img, and you are in a directory you cannot write to, it will try to create it in that directory, and fail. You can check your current working directory by running the pwd command.

As for the ssh command, the port number is specified using the -p flag, rather than a :, such as you would do with a URL. To connect to port 35000, you would alter your command to look more like this:

ssh -p 35000 root@12.34.56.78 "dd if=/dev/sda " | dd of=/home/archive/linode.img

That said, it is not necessary to change your SSH port from it's default during this process. The Linode will only be in this state for a short period, and obfuscating your SSH port doesn't do anything to increase security anyway, as it is pretty easy to determine which port a given service is actually running on. Since anything configured in Rescue Mode requires re-configuring after each reboot, you can simply reboot and re-apply the SSH settings without changing the port number.

I have a script which automates this whole process, using Bash and the Linode CLI.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct