There are three options I am aware of
Port Forwarding
You can set up port forwarding for each device you want to be be able to connect to externally.
- This assumes you know your external IP address.
For each device you could assign an arbitrary external port that forwards to that device on port 22. (Or you can do this for one device, and then connect to the others through it)
VPN
Were you to make a VPN with your local network, and then connect to said VPN, it would give you access to everything on on the network.
Reverse SSH
With reverse SSH you make use of an external server, and set up a listening ssh session. Then, on the external server you can connect to the device behind the router without being bothered by firewalls/port forwarding/etc...
This is what I prefer (as I haven't set up a VPN yet), but I have access to an external server.
You could do this with:
Device on home network ssh -f -N -R 1234:localhost:22 remote_user@remote.server.example
- Where
1234
is the port that remote would use forward to the device
remote.server.example
is the remote's address
Then, on the remote server ssh -p 1234 -t device_user@localhost
are you referring to port forwarding or agent forwarding? By default, port forwarding isn't enabled unless you use -L or -R options.
Agent forwarding (for authentication using keys in your local ssh-agent) can be enabled by using
ssh -A <user>@<host>
Let me know if this is helpful.
Best Answer
You can use the
-p
option to choose a different port. So:You can also look up help using the
man
(manual) command, likeman ssh
, to show help information, including usage, command line options, errors, etc. While in the man page, you can type/
(the slash character) followed by any text (and Enter) to search for that within the manual.