Day 14 Learnings: Remote Access and File Transfers in Linux
Today's Linux journey focused on remote access and secure file transfers, essential skills for managing servers and transferring data over networks securely. I explored the ssh
command for remote server connections and the scp
command for copying files between systems.
What I Learned This Week
Using the
ssh
Command:
Securely connect to a remote server via the command line.Using the
scp
Command:
Transfer files between local and remote systems securely.
Steps I Followed
Connecting to a Remote Server | ssh
Command
Basic SSH Connection:
Connected to a remote server using its username and IP address:ssh user@remote-server-ip
Specify a Port for SSH:
Connected to a server running SSH on a non-default port (e.g., 2222):ssh -p 2222 user@remote-server-ip
Copy SSH Public Key to Server:
Set up key-based authentication for passwordless login:ssh-copy-id user@remote-server-ip
Run Commands on a Remote Server:
Executed a single command on the remote server without opening an interactive shell:ssh user@remote-server-ip 'ls -la'
Secure File Transfer | scp
Command
Copy File to a Remote Server:
Transferred a file to the remote server's home directory:scp file.txt user@remote-server-ip:/home/user/
Copy File from a Remote Server:
Retrieved a file from the remote server to the local system:scp user@remote-server-ip:/home/user/file.txt /local/directory/
Copy a Directory Recursively:
Transferred a directory and its contents to a remote server:scp -r /local/directory user@remote-server-ip:/remote/directory/
Specify an SSH Port for SCP:
Used a custom SSH port for secure file transfer:scp -P 2222 file.txt user@remote-server-ip:/home/user/
Problems I Encountered
Permission Denied During SSH Login:
Could not log in due to missing permissions on the SSH key.Slow File Transfers with SCP:
Large files took longer to transfer, causing delays.
How I Solved These Problems
Fixing SSH Permissions:
Adjusted permissions on the SSH private key:chmod 600 ~/.ssh/id_rsa
Using Compression in SCP:
Enabled compression during file transfer to speed up the process:scp -C file.txt user@remote-server-ip:/home/user/
Resources I Used
Linuxize Guide to SSH Command
Linuxize Guide to SCP Command
Forums for troubleshooting SSH key permissions and SCP optimizations.
Conclusion
Today’s topics provided insights into connecting to remote servers securely using SSH and transferring files efficiently with SCP. These tools are invaluable for managing remote systems and handling data securely.
Excited to delve into more Linux topics tomorrow in Day 15!