How to connect remote shell through SSH in Linux over internet?
How to connect SSH in Linux?
In Linux, How to connect through SSH over LAN and WAN, What makes the difference from LAN and WAN, How is it achieved over WAN i.e. over internet?
One of the ways is to configure your server side router to allow SSH. i.e. Through PORT FORWARDING
Usually within a LAN environment, it is through the terminal you can login into the remote desktop through the SSH command and the IP address.
#ssh 192.168.0.101
#ssh username@ipaddress
You need to install SSH Server in the system you wish to login i.e. Remote System
How to install SSH Server on Linux?
Ubuntu
#sudo apt-get install openssh-server
Redhat
#yum install openssh-server
Arch
#sudo pacman -S openssh
After installing SSH Server you need to start the sshd.
Within the LAN
To login remote SSH, you need remote login password.
ssh user@ipaddress
#ssh user@192.168.0.101
Before you login, make sure 'sshd' service is started in the remote system. By default SSH server start listening on 'port 22'. After installing SSH Server, you can check the status with the below command.
#sudo systemctl start sshd
#sudo systemctl status sshd
#sudo systemctl restart sshd
Without need to start the ssh server manually, if the service is enabled it will start on every reboot. The same way you can disable the service too.
#sudo systemctl enable sshd
#sudo systemctl disable sshd
How to find your IP Address? Through 'ifconfig' command.
To use this command 'ifconfig' you need to install 'net-tools'
#ifconfig
Ubuntu
#sudo apt-get install net-tools
arch
#sudo pacman -S net-tools
Now you can login to remote shell within the LAN, you can achieve the same over the internet using PORT FORWARDING.
For PORT FORWARDING login to your server side router and open firewall settings, in the IPv4 and IPv6 add new rules for SSH. Configurations for routers may differ so I am giving an example of a router configuration.
Use IPv6 address to login to your remote shell over internet.
Thank you, All the best.
Else you can check with this link for your IP Address.
Note : Check your firewall settings