SSH(Secure Shell )
Secure Remote Access with SSH
SSH, or Secure Shell, is a method for securely connecting to another computer over a network. It enables you to remotely access and control another computer as if you were physically present.
How SSH Works
Secure Connection: SSH establishes an encrypted link between your computer and the remote one, ensuring that your data remains private and secure.
Remote Control: Once connected, you can execute commands on the remote computer, transfer files, and perform various tasks just like you would on your own computer.
Setting Up SSH
On Windows
If you're using Windows, install PuTTY for SSH access. PuTTY provides a terminal where you can enter SSH commands. For mobile devices, Termux offers a Linux environment.
On Linux
Note : am on arch linux do run commands according to your linux version .
For a more secure experience, use the Linux terminal:
Install Net Tools: Use your package manager to install net-tools.
comm : (sudo pacman -Syu net-tools)
Install OpenSSH Server: Use your package manager to install openssh-server. comm : (sudo pacman -Syu openssh-server)
Now up the server in both systems (own system or remote system):
comm : sudo systemctl enable sshd # to up the ssh server
comm : sudo systemctl status sshd # to check the status of the server
you can also restart the service if you want :- comm : sudo systemctl restart sshd
-
Check Remote Server IP: Use comm : ifconfig to find the server's IP address (look for
inetfollowed by the IP address).
Now you can connect to your remote machine securely without relying on external services.
Now here am making connection with my own system : (known as lopback connection):
Do remember it is the password connection(for this type of ssh you need to know to password of remote system):
First you need to check the ip and make sure if you connecting two differnet system so internet should be same .
comm : ifconfig
comm : ssh username@ip
Now you can check you have made the connection successfully .
If you wannt to logout the connection :
comm : exit
Passwordless Login to Remote Machine
Enhance security by using SSH keys instead of passwords:
Generate SSH Key: Use ssh-keygen to generate an SSH key pair. Press Enter to skip passphrase. comm : (ssh-keygen)
Copy Key to Remote Machine: Use ssh-copy-id to copy the public key to the remote server. comm : (ssh-copy-id -i filename remoteip)
ex : ssh-copy-id -i ~/key.pub Ahmed.Dawood@192.168.18.161
Login Without Password: Use ssh -i to login to the remote machine without entering a password. comm : (ssh -i filename remoteip)
ex : ssh -i ~/yes Ahmed.Dawood@192.168.18.161
Terminate Remote Session: To disconnect, find the process ID and terminate it using sudo kill. comm : (sudo kill process id )
ps aux | grep sshd
sudo kill pid
You can use test experiments on remote machine
Running a Secure Experiment
To ensure your connection remains stable, even during network interruptions, run a Python experiment as follows:
Start the Experiment: Run your Python script in the background using nohup no hang-up. comm : (nohup python3 p0573.py > p0573.log &)
Monitor Experiment Log: Use tail to monitor the log file in real-time.
comm : (tail -f p0573.log)
Terminate the Experiment: To stop the experiment, identify its process ID and terminate it. Find the process id command comm : (ps aux | grep process) to kill the process comm : (kill -9 process id)
ps aux | grep sshd
sudo kill pip
Conclusion
Following these steps ensures a secure and efficient connection between your computers. Every mistake is a chance to learn and improve your SSH skills.
Additional Resources
For more SSH tips and tricks, consider watching tutorial videos and reading blogs. Check out this YouTube video (https://www.youtube.com/watch?v=kdiz66KZrBg&list=LL&index=9) for detailed guidance.
Author: Haris
FAST '27
BS CS
Member:
Research Lab COLAB-NU
Email: arainharis151@gmail.com
Feel free to reach out for questions or further assistance. Happy computing!







Comments
Post a Comment