|< Day Day Up >|
Recipe 13.6. Copying Files to Another Linux PC
You want to copy files from a troubled PC to another machine on your network. This is a good way to do an emergency backup of critical files when a PC appears to be dying or behaving strangely.
Boot up Knoppix. The troubled PC must then connect to the LAN. If you have a DHCP server, Knoppix will connect automatically.
If you need to configure a static IP address, run netcardconfig from the console, or use Knoppix Network/Internet.
You'll need an SSH server set up on the receiving machine. (See the "Discussion" section of this recipe if you need to set this up.)
First, mount the filesystem containing the files you want to copy. Knoppix creates /etc/fstab, puts all the mountpoints under /mnt, and creates desktop icons for all filesystems. The easy way to mount the filesystem is to click on the desktop icon. Or you can peek into /etc/fstab and use the command line. First change to root. There is no password:
knoppix@tty0[knoppix]$ su root@ttyp0[knoppix]# mount /mnt/hda5
Then run the scp (secure copy) command:
# scp -rp /mnt/hda5/home/kmartin 192.168.1.5:/home/kmartin/tmp
It will complain:
Could not create directory '/home/kmartin/.ssh'. The authenticity of host '192.168.1.5 (192.168.1.5)' can't be established. RSA key fingerprint is a2:c6:77:2e:63:b2:ed:90:b2:9b:bc:e7:d4:22:ba Are you sure you want to continue connecting?" (yes/no)?
Say yes. Then it will ask you for root's password on the SSH server. Enter the password, and the files will be copied.
You can also do this as an ordinary user, for the user's own account. At the Knoppix root prompt, create a new user:
root@ttyp0[knoppix]# useradd kmartin
Don't bother with a password—you only need the user's password on the SSH server. Now kmartin can move files into her own account on the SSH server. Only root can copy files into other users' accounts.
The -r option for scp copies directories recursively. -p preserves permissions.
This is how to set up a quick-and-dirty SSH server. Install OpenSSH on the Linux machine to which you want to copy files. If it's already installed, upgrade to the latest version to get all the security fixes. Then start it up:
# /etc/init.d/ssh start
and it is ready to receive files. If you intend to use SSH routinely for remote administration, don't stop here—you'll need to take a few more steps to ensure a safe connection. See Chapter 17 for more recipes on running SSH.
Because you are running Knoppix in memory, there is no way to save SSH keys or hosts, so it will emit the same complaints every time. If you plan to make a habit of copying files via scp, see Recipe Recipe 13.5.
13.6.4 See Also
|< Day Day Up >|