LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-11-2015, 02:31 PM   #1
hammer65
LQ Newbie
 
Registered: Jun 2005
Location: Midwest
Distribution: Fedora
Posts: 20

Rep: Reputation: 0
Question on a second machine using SSH


So I have three machines I want to expose to the outside in order to access them from work and other places.Two of them are already set up and running and have been for some time. One is a CENTOS 6 box running a web server, the other is a PPC mac that I use mostly for files using SFTP.

I have a dyndns account which I use and the router set up to forward ports accordingly, but I want to add another machine on which I do work from home (Ubuntu 14.04), which will allow me to access git repositories remotely. the other box I use for SSH/SFTP won't be suitable for the task so my question is what are my options for adding another machine that uses SSH? Different port or can I use the machine name somehow to get to that box seperate from the other? I'm afraid I'm not quite knowledgable enough about networking to get this one done myself. Any help would be appreciated. thanks

Last edited by hammer65; 01-11-2015 at 02:32 PM.
 
Old 01-11-2015, 02:43 PM   #2
notKlaatu
Senior Member
 
Registered: Sep 2010
Location: Lawrence, New Zealand
Distribution: Slackware
Posts: 1,077

Rep: Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732
I'm guessing that these boxen are behind a router/firewall; so you knock at your home IP via dyndns and then get routed to internal addresses. If that's the case, it probably is easiest to just use a different port for ssh'ing into each, if it's all the same to you. You can set unique dyndns aliases for each port, and then route it to the correct box you want to use based on what external port you are coming in from.
 
Old 01-11-2015, 03:03 PM   #3
Miati
Member
 
Registered: Dec 2014
Distribution: Linux Mint 17.*
Posts: 326

Rep: Reputation: 106Reputation: 106
Are these all in the same lan?

You can have #1 listen at port 22, #2 port 2200, #3 port 2201, etc. Then forward the ports to the appropriate sshd service.

You can also just have one connection open to the outside, then once logged in, then access the second computer. Or just do it all in one command
If I was trying to login to my server (999.99) then my home computer (192.168.1.23)

Code:
ssh -t 999.99 ssh 192.168.1.23
 
Old 01-11-2015, 03:08 PM   #4
hammer65
LQ Newbie
 
Registered: Jun 2005
Location: Midwest
Distribution: Fedora
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Miati View Post
Are these all in the same lan?

You can have #1 listen at port 22, #2 port 2200, #3 port 2201, etc. Then forward the ports to the appropriate sshd service.

You can also just have one connection open to the outside, then once logged in, then access the second computer. Or just do it all in one command
If I was trying to login to my server (999.99) then my home computer (192.168.1.23)

Code:
ssh -t 999.99 ssh 192.168.1.23
that's what I had been doing for some of the other machines on the network which didn't need direct exposure through the firewall. With Git I don't know that that would work. I may have to go with a different port, which is fine. I just wondered if there might be a better way.
 
Old 01-11-2015, 03:12 PM   #5
hammer65
LQ Newbie
 
Registered: Jun 2005
Location: Midwest
Distribution: Fedora
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by notKlaatu View Post
I'm guessing that these boxen are behind a router/firewall; so you knock at your home IP via dyndns and then get routed to internal addresses. If that's the case, it probably is easiest to just use a different port for ssh'ing into each, if it's all the same to you. You can set unique dyndns aliases for each port, and then route it to the correct box you want to use based on what external port you are coming in from.
They are yes. One box is set to recieve anything coming in on 80 (CentOS box) and the other is set accept everything on 22 (PPC Mac). Thing is the mac has enough disk for the Git stuff but I've had issues with Git on PPC OS x and really don't have the patience to deal with it and I'd rather have the Git repositories on the machine I do development on. So port 2200 it is.
 
Old 01-11-2015, 03:14 PM   #6
Miati
Member
 
Registered: Dec 2014
Distribution: Linux Mint 17.*
Posts: 326

Rep: Reputation: 106Reputation: 106
Quote:
Originally Posted by hammer65 View Post
With Git I don't know that that would work.
Perhaps sshfs?

On the computer currently directly exposed to the web, run sshfs to mount the git repositories you need (within lan right?) so that it is directly accessible through that computer.

e.g.

If my git repos are located at computer A ( 192.168.1.22 ) and my computer B is the one with a ssh service facing the internet, on computer B I would run
Code:
sshfs 192.168.1.22:/dir/to/gitrepos /media/gitrepo
Then anyone accessing computer b from the net would be able to access /media/gitrepo without needing to do a second login.
Since you are more or less just trying to access files, this would let you consolidate files into one server without using any extra space.

Last edited by Miati; 01-11-2015 at 03:16 PM.
 
Old 01-11-2015, 03:16 PM   #7
Doug G
Member
 
Registered: Jul 2013
Posts: 749

Rep: Reputation: Disabled
you can use ssh port forwarding to set up a tunnel to another lan machine rather than forwarding multiple ports in your router.

ssh -L 12345:<lan ip>:22 will allow you to open a 2nd ssh session on your remote workstation using port 12345 and get to the 2nd machine ( ssh -p 12345 localhost ).

Last edited by Doug G; 01-11-2015 at 07:24 PM.
 
1 members found this post helpful.
Old 01-11-2015, 05:09 PM   #8
hammer65
LQ Newbie
 
Registered: Jun 2005
Location: Midwest
Distribution: Fedora
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Miati View Post
Perhaps sshfs?

On the computer currently directly exposed to the web, run sshfs to mount the git repositories you need (within lan right?) so that it is directly accessible through that computer.

e.g.

If my git repos are located at computer A ( 192.168.1.22 ) and my computer B is the one with a ssh service facing the internet, on computer B I would run
Code:
sshfs 192.168.1.22:/dir/to/gitrepos /media/gitrepo
Then anyone accessing computer b from the net would be able to access /media/gitrepo without needing to do a second login.
Since you are more or less just trying to access files, this would let you consolidate files into one server without using any extra space.
This might work, but given that the Mac can't run Git worth spit, I would need to switch the Ubnutu machine as the machine exposed to the outside and then mount a sshfs volume from the mac onto the Ubuntu machine so that both were accessible that way. Thank you for the suggestion. That might be the way to go.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to access a windows machine GUI from a linux machine using ssh obarhleam Linux - Newbie 6 07-11-2012 07:46 AM
[SOLVED] How can I ssh/scp into a remote's machine local machine? venom4u31 Linux - Newbie 6 11-05-2011 01:36 PM
not able to ping a machine but can do ssh to machine , wanna run vnc client amolgupta Linux - Software 4 07-28-2009 05:17 PM
SSH forward from a Windows machine to a Linux machine isn't working nickj6282 Linux - Networking 3 08-13-2006 02:47 PM
how to open a dilog on local machine when i do ssh to remote machine fahad26 Programming 3 05-03-2005 07:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration