To connect to another computer in your local network using SSH, follow these steps:
- Ensure both computers are on the same local network.
- Find the IP address of the target computer.
- On Linux/macOS: Use the command
ip a or ifconfig in the terminal.
- On Windows: Use the command
ipconfig in Command Prompt.
- Ensure the target computer has an SSH server installed and running.
- On Linux: Install with
sudo apt install openssh-server and start with sudo systemctl start ssh.
- On Windows: Enable OpenSSH Server via Settings or PowerShell.
- From the client computer, use an SSH client to connect to the target computer's IP address.
- On Linux/macOS: Use the command
ssh username@target_ip_address in the terminal.
- On Windows: Use PuTTY or the built-in SSH client.
For example, if both computers are running Linux:
-
On the target computer, install and start the SSH server, then find its IP address:
sudo apt update
sudo apt install openssh-server
sudo systemctl start ssh
ip a
Suppose the IP address is 192.168.1.100.
-
On the client computer, connect using:
ssh user@192.168.1.100
Replace user with the actual username on the target computer.
You'll be prompted to enter the password for the user on the target computer. Once authenticated, you'll be connected to the target computer via SSH.
If the target computer is running Windows, you'll need to enable the OpenSSH Server feature first. This can be done through the Settings app under "Apps" > "Optional Features" > "Add a feature" > "OpenSSH Server". Alternatively, you can enable it via PowerShell with administrative privileges using the following commands:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType Automatic
After enabling the SSH server on Windows, you can find the IP address using ipconfig in Command Prompt and then connect from the client computer using the appropriate SSH client as described above.
If the client computer is running Windows, you can use PuTTY or the built-in SSH client. For PuTTY, you would enter the target computer's IP address and port (default is 22), then click Open. For the built-in SSH client, you can use the following command in Command Prompt or PowerShell:
ssh username@target_ip_address