Connecting using SSH in WAN network

i have been learning linux from some time for linux plus exam and learned SSH protocol and have practised to connect to remote computer within Lan network and able to sucesssfully connect it .
using

ssh username@hostname

But i wish to ask how do i use same ssh protocol to connect to other linux computer on other part of world ie in WAN

Hi,

You do it exactly the same way. The ssh command itself doesn't care what or where a host is, it will just try to connect to it. So long as the hostname you use can be resolved, or you're using an IP address, there shouldn't be any issues.

Now, other things may very well stop you from connecting of course. You might have no route to the destination network, a local firewall that blocks the outbound connection, a remote firewall that blocks the inbound connection, etc, etc. Any number of things could get in the way.

But in terms of the ssh command itself, there's no difference in how you connect to a host on your own LAN or on some other network entirely.

1 Like

The syntax is the same. There are network setups for security that may prevent this, but that is beyond the scope of what you are asking.

1 Like

thank you guys. finding my hostname or local ip address of system within LAN network is quite easy through

ifconfig

. but i cannot use that physical address of LAN network to connect to other network that pass through Router. So can u guys give me how should i go about it ..

Hi,

I'm sorry, I don't understand. As long as you know the hostname or IP address of the server you want to connect to, then you don't need to know anything else. It's got nothing to do with your own hostname or IP address at all. Connecting to a remote system only needs you to know the details of the remote system.

For example, if you wanted to connect to a host called server.acme.com as the user jsmith , you would simply type:

ssh jsmith@server.acme.com

and that would be that.

Thanks for your patience . my idea is to connect my computer from england to my friend computer in USA. both are pc with linux os installed and connected to internet. how can i find the hostname or ip address of my friend computer in usa.

Hi,

To connect to your friends computer in the USA should be quite simple, if your friend cooperates with you.

However there are a number of things that you must know and a number of things that you must setup at both ends of the link.

You need to know the IP Address or name of the computer that you are trying to connect to - you can generally find this by visiting "whatsmyip" or a similar service - please note it will be your friend that will have to provide you with this information.

Your friend will have also have to have a fixed IP Address or use one of the dynamic dns services as the target IP Address will likely change from time to time.

The remote end will also have to have the appropriate ports open (22 in the case of ssh) or port forwarding or some protocol like NAT (Network Address Translation) setup.

At your end you will also have to have the correct settings for your router, firewall etc.

Regards

Gull04