Ubuntu: SSH from iPhone



Question:

I installed openssh server on Ubuntu 14.04. My machine name is called "machine" and my username is "machine" so that when I'm on a terminal it says "machine@machine".

Question: When I try to connect to my machine from an SSH client (iPhone through 3G), what do I type in for:

  1. username
  2. example.hostname.com:port

I assume the answer to (1) is "machine". But what about (2)? How do I find out my hostname and port?


Solution:1

The best way is to get the machines IP address and connect the server. Also you can connect with the Mobile Terminal program from Cydia with the command

ssh machine@IP (If the default port 22 is not changed)

If port changed

ssh -p portnumber machine@ipaddress


Solution:2

This will depend on if you are connecting on your local network, or trying to connect from a remote network (across the Internet).

You mentioned that your username on your computer is "machine", so this is what you would enter for the ssh username.

Regarding the second part of your question "example.hostname.com:port":

If both your computer and your iPhone are connected to the same network, you need to know the IP address of your computer. On your computer, you can open up a terminal and type

ip a  

If your computer is connected by an ethernet cable, look under the "eth0" listing to find the "inet" address. If it is connected wirelessly, look under the "wlan0" listing. It will look something like 192.168.1.5 or 10.0.1.5, or something to that effect. This is the address you will use when you connect from your iPhone. If you did not change the ssh port number, then you shouldn't have to specify it, as it will default to port 22.

So, for example, if your computer's IP address were 192.168.1.5, you would enter that, instead of "example.hostname.com:port".

If you are trying to connect to your computer from a remote network (across the Internet), then you'll have a few more steps. You will need to make sure that you have the ssh port 22 forwarded on your router to your computer's IP address (assuming you have control of your router and can make such modifications). And then you will need to know your external public IP address. That external address will be what you enter into your iPhone ssh client. You can find your external IP address easily from your computer by visiting a site such as http://www.ipchicken.com. Then you would enter that, instead of "example.hostname.com:port".

However, if you are trying to connect remotely to a residential ISP account, you will most likely be given a DHCP lease from your ISP. Which means your external IP address will change regularly. The time your IP address lease lasts varies from ISP to ISP. It could be a few hours, to a few days. So you may need to regularly check your external address to make sure you have the correct one.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »