Red Hat System Administration II
Copy files from a remote system to a local directory with sftp.
Outcomes
Copy files from a remote host to a directory on the local machine.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start archive-transfer
Instructions
Use the
sshcommand to log in toserveraas thestudentuser.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$Use the
sftpcommand to copy the/etc/sshdirectory from theserverbmachine to the/home/student/serverbackupdirectory on theserveramachine.On the
serveramachine, create a/home/student/serverbackupdirectory.[student@servera ~]$
mkdir ~/serverbackupUse the
sftpcommand to open a session to theserverbmachine. Only therootuser can read all the content in the/etc/sshdirectory. When prompted, enterredhatas the password.[student@servera ~]$
sftp root@serverbroot@serverb's password:redhatConnected to serverb. sftp>Change the local current directory to the newly created
/home/student/serverbackupdirectory.sftp>
lcd /home/student/serverbackup/sftp>lpwdLocal working directory: /home/student/serverbackupRecursively copy the
/etc/sshdirectory from theserverbmachine to the/home/student/serverbackupdirectory on theserveramachine.sftp>
get -r /etc/sshFetching /etc/ssh/ to ssh Retrieving /etc/ssh Retrieving /etc/ssh/sshd_config.d 50-redhat.conf 100% 719 881.5KB/s 00:00 Retrieving /etc/ssh/ssh_config.d 50-redhat.conf 100% 581 347.4KB/s 00:00 01-training.conf 100% 36 25.8KB/s 00:00 moduli 100% 565KB 71.9MB/s 00:00 ssh_config 100% 1921 1.1MB/s 00:00 ssh_host_rsa_key 100% 2602 7.2MB/s 00:00 ssh_host_rsa_key.pub 100% 565 1.6MB/s 00:00 ssh_host_ecdsa_key 100% 505 1.6MB/s 00:00 ssh_host_ecdsa_key.pub 100% 173 528.6KB/s 00:00 ssh_host_ed25519_key 100% 399 1.0MB/s 00:00 ssh_host_ed25519_key.pub 100% 93 275.8KB/s 00:00 sshd_config 100% 3730 10.3MB/s 00:00Exit from the
sftpsession. Verify that the/etc/sshdirectory from theserverbmachine is copied to the/home/student/serverbackupdirectory on theserveramachine.sftp>
exit[student@servera ~]$ls -lR ~/serverbackup/home/student/serverbackup: total 4 drwxr-xr-x. 4 student student 4096 Mar 21 12:01 ssh /home/student/serverbackup/ssh: total 600 -rw-r--r--. 1 student student 578094 Mar 21 12:01 moduli -rw-r--r--. 1 student student 1921 Mar 21 12:01 ssh_config drwxr-xr-x. 2 student student 52 Mar 21 12:01 ssh_config.d -rw-------. 1 student student 3730 Mar 21 12:01 sshd_config drwx------. 2 student student 28 Mar 21 12:01 sshd_config.d -rw-r-----. 1 student student 505 Mar 21 12:01 ssh_host_ecdsa_key -rw-r--r--. 1 student student 173 Mar 21 12:01 ssh_host_ecdsa_key.pub -rw-r-----. 1 student student 399 Mar 21 12:01 ssh_host_ed25519_key -rw-r--r--. 1 student student 93 Mar 21 12:01 ssh_host_ed25519_key.pub -rw-r-----. 1 student student 2602 Mar 21 12:01 ssh_host_rsa_key -rw-r--r--. 1 student student 565 Mar 21 12:01 ssh_host_rsa_key.pub /home/student/serverbackup/ssh/ssh_config.d: total 8 -rw-r--r--. 1 student student 36 Mar 21 12:01 01-training.conf -rw-r--r--. 1 student student 581 Mar 21 12:01 50-redhat.conf /home/student/serverbackup/ssh/sshd_config.d: total 4 -rw-------. 1 student student 719 Mar 21 12:01 50-redhat.conf
Return to the
workstationsystem as thestudentuser.[student@servera ~]$
exitlogout Connection to servera closed. [student@workstation]$