Red Hat Enterprise Linux Diagnostics and Troubleshooting
Solve a Secure Copy Protocol (SCP) file transfer issue.
Outcomes
You should be able to solve an SCP file transfer issue by using the scientific method.
As the student user on the workstation machine, use the lab command to prepare your systems for this lab.
[student@workstation ~]$ lab start strategy-review
This command creates the necessary files to perform this lab.
Instructions
The student user on workstation reported that they are unable to copy a file from serverb by using SCP.
The user provided the following information:
The file that they are trying to copy is
/home/student/document.txt.They are trying to copy the file to the
studentuser's home directory onworkstation.They are connecting to
serverbas thestudentuser.
Note
The purpose of this lab is to implement the scientific method to troubleshoot an issue, regardless of how simple the issue is. Force yourself to exaggerate the process to understand the importance of each step.
Collect relevant information.
Login to
serverband switch to therootuser.[student@workstation ~]$
ssh student@serverb...output omitted... [student@serverb ~]$sudo -i[sudo] password for student:student[root@serverb ~]$Gather information about the
sshdservice. SCP relies onsshdto function and the status would report any recent errors.[root@serverb ~]$
systemctl status sshd.service● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2021-09-15 09:07:20 EDT; 7h ago ...output omitted...Gather information about the
/home/student/document.txtfile.[root@serverb ~]$
ls -l /home/studenttotal 0 -rw-r-----. 1 consultant consultant 0 Sep 20 09:41 document.txtGather information about potential SELinux alerts. If the output is blank, then no alerts were found.
[root@serverb ~]$
cat /var/log/messages | grep sealertReturn to
workstationas thestudentuser.[root@serverb ~]#
exit[student@serverb ~]$exit[student@workstation ~]$From
workstation, attempt to re-create the issue.[student@workstation ~]$
scp student@serverb:~/document.txt .scp: /home/student/document.txt: Permission deniedObserve the error message and consider the information that you gathered from the previous steps.
Create a problem statement.
Formulate testable hypotheses.
The following hypotheses are exaggerated to demonstrate other plausible real-world scenarios. Some of these hypotheses ignore information from the information gathering step for the sake of testing multiple hypotheses.
serverbis not reachable over the network. Test by accessing network interfaces with network tools.The
sshdprocess onserverbis not running or is misconfigured. Test by using SSH to log in to the system.SELinux on
serverbis preventing the file transfer. Test by temporarily disabling SELinux./home/student/document.txthas incorrect file permissions. Test by addingreadpermissions.
Test each hypothesis.
Test the hypothesis that
serverbcannot be reached over the network with network tools.[student@workstation ~]$
ping serverbPING serverb.lab.example.com (172.25.250.11) 56(84) bytes of data. 64 bytes from serverb.lab.example.com (172.25.250.11): icmp_seq=1 ttl=64 time=0.861 ms ...output omitted...The hypothesis that
serverbis not reachable can be eliminated because thepingcommand succeeds.Test the hypothesis that the
sshdprocess onserverbis not running properly by attempting to run a remote SSH command on the system.[student@workstation ~]$
ssh student@serverb echo test message on serverbtest message on serverbThe hypothesis that the
sshdprocess onserverbis not functioning can be eliminated because thesshcommand succeeds.Test the hypothesis that SELinux on
serverbis preventing the file transfer by disabling SELinux.[student@workstation ~]$
ssh root@serverb setenforce 0[student@workstation ~]$scp student@serverb:~/document.txt .scp: /home/student/document.txt: Permission denied [student@workstation ~]$ssh root@serverb setenforce 1The hypothesis that SELinux is preventing the file transfer can be eliminated because disabling SELinux did not resolve the issue. Notice that the change was immediately reversed after it was tested and eliminated as a possible issue.
Test the hypothesis that a file permission issue is preventing the file transfer.
[student@workstation ~]$
ssh root@serverb chown student:student /home/student/document.txt[student@workstation ~]$scp student@serverb:~/document.txt .document.txt 100% 0 0.0KB/s 00:00It appears that the issue was likely caused by incorrect file permissions.
Record and analyze the test results.
Fix and verify the problem resolution.
In this lab's case, no further fixes are required to resolve the issue permanently. The issue can be marked as resolved, given that the current state is the inverse of the problem statement: "Now, the
studentuser reports that they are able to use thescpcommand to transfer the/home/student/document.txtfile fromserverbtoworkstation, without any error messages."