In this exercise, you 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 ssh command to log in to servera as the student user.
[student@workstation ~]$ ssh student@servera
...output omitted...
[student@servera ~]$Use the sftp command to copy the /etc/ssh directory from the serverb machine to the /home/student/serverbackup directory on the servera machine.
On the servera machine, create a /home/student/serverbackup directory.
[student@servera ~]$ mkdir ~/serverbackupUse the sftp command to open a session to the serverb machine.
Only the root user can read all the content in the /etc/ssh directory.
When prompted, enter redhat as 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/serverbackup directory.
sftp>lcd /home/student/serverbackup/sftp>lpwdLocal working directory: /home/student/serverbackup
Recursively copy the /etc/ssh directory from the serverb machine to the /home/student/serverbackup directory on the servera machine.
sftp> get -r /etc/ssh
Fetching /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 sftp session. Verify that the /etc/ssh directory from the serverb machine is copied to the /home/student/serverbackup directory on the servera machine.
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 workstation system as the student user.
[student@servera ~]$ exit
logout
Connection to servera closed.
[student@workstation]$This concludes the section.