SSH(Secure Shell )

·

3 min read

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:

  1. Install Net Tools: Use your package manager to install net-tools.

    comm : (sudo pacman -Syu net-tools)

  2. 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 :

  3. comm : sudo systemctl restart sshd

  4. Check Remote Server IP: Use comm : ifconfig to find the server's IP address (look for inet followed 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:

  1. Generate SSH Key: Use ssh-keygen to generate an SSH key pair. Press Enter to skip passphrase.

  2.  ssh-keygen
    
  3. Copy Key to Remote Machine: Use ssh-copy-id to copy the public key to the remote server. comm :

  4.  ssh-copy-id -i filename remoteip
    
  5. Login Without Password: Use ssh -i to login to the remote machine without entering a password.

ssh -i filename remoteip
  1. Terminate Remote Session: To disconnect, find the process ID and terminate it using sudo kill.

  2.   ps aux | grep sshd
    
  3.  sudo kill process id
    
  4. You can use test experiments on remote machine


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.

P.S.

If you spot any mistakes, please don't hesitate to point them out. We're all here to learn together! 😊

Haris
FAST (NUCES)
BS Computer Science | Class of 2027

📌 GitHub: https://github.com/Zenvila
📌 LinkedIn: https://www.linkedin.com/in/haris-shahzad-7b8746291/
📌 Member: COLAB (Research Lab)