[SOLVED] How can I ssh/scp into a remote's machine local machine?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How can I ssh/scp into a remote's machine local machine?
I want the address format of that. Allow me to explain:
I am in location A;
A server is in location B;
The server runs linux and has an active virtual machine on it (also running linux).
I know the address of the server (server.address.com) and I know the local ip (192.168.0.1) address of the virtual machine.
I have winscp and I want to access the virtual machine on that remote server directly so I'll download a file off of it on my pc in location A.(note that the internet connection is not a problem)
username on remote server= gauss
username on virtual machine= root (with uid=0)
Please give me a concrete example of code. I want to access the virtual machine directly on winscp, not access the server, and run some commands. I just don't know the address format.
Note that any data given (no matter of what kind it appears to be) is for example purposes only. Any reference to external sources is purely unintentional. In other words, my server is not hosted on address.com and the username is not really gauss. However, I do have root privileges on the virtual machine.
Last edited by venom4u31; 11-04-2011 at 06:50 PM.
Click here to see the post LQ members have rated as the most helpful post in this thread.
I don't think you can login to this virtual machine directly because the virtual machine's address is on the 192.168.*.* subnet which is always considered a local subnet -- it's one of those weird realms of the IP universe reserved for local machines only so it means a different machine for more or less everyone in the entire world.
You might be able to set up some kind of proxy or packet forwarding type thing on the Server in location B, but you are going to have to talk to Server B first and have it act as a go-between for you. There might also be some way to have the virtual machine bound to a different IP address -- i.e., one that is meaningful to the internet at large.
I don't think you can login to this virtual machine directly because the virtual machine's address is on the 192.168.*.* subnet which is always considered a local subnet -- it's one of those weird realms of the IP universe reserved for local machines only so it means a different machine for more or less everyone in the entire world.
You might be able to set up some kind of proxy or packet forwarding type thing on the Server in location B, but you are going to have to talk to Server B first and have it act as a go-between for you. There might also be some way to have the virtual machine bound to a different IP address -- i.e., one that is meaningful to the internet at large.
Alright, and if that virtual machine has the ip address (for example) 10.23.6.1, how will I connect to it in the circumstances shown above?
You haven't specified what kind of connection you need. There's also the question of what kind of connections a linux machine supports. There's also the question of what user credentials you have for the various machines. I often connect using SSH from my windows machine to an Ubuntu linux machine on my LAN using PuTTY and then from the command line, I connect to a remote machine like so:
Code:
ssh username@10.23.6.1
and am prompted for a password...
...UNLESS of course the remote machine has SSHD configured to permit only certificate-based logins, etc.
But in order to transfer files from machine to machine you might have to use the scp command. You might do something like this:
1) Login to 10.23.6.1 using ssh from a mac or *nix machine OR using puTTY from a windows machine
2) use scp command from that linux machine to copy a file from the virtual machine (192.168.0.1) to the linux machine.
3) logout from the linux machine and then use scp from your local mac or *nix machine OR pscp from your windows machine to copy the file locally.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
I assume your remote server and the VM on it share the same subnet.
Then you can build an SSH tunnel. Assume winscp uses port 2200. Open a terminal and build the tunnel:
ssh -L 8000:192.168.0.1:2200 remote.server.com
What did you do? As soon as you logged in on remote.server.com, you built a tunnel which translates port 8000 on you local host to port 2200 on 192.168.0.1 on the other side (B).
So in order to use winscp, (no idea what it is) winscp localhost:8000
That is right, localhost:8000 gets translated to 192.168.0.1:2200
I assume your remote server and the VM on it share the same subnet.
Then you can build an SSH tunnel. Assume winscp uses port 2200. Open a terminal and build the tunnel:
ssh -L 8000:192.168.0.1:2200 remote.server.com
What did you do? As soon as you logged in on remote.server.com, you built a tunnel which translates port 8000 on you local host to port 2200 on 192.168.0.1 on the other side (B).
So in order to use winscp, (no idea what it is) winscp localhost:8000
That is right, localhost:8000 gets translated to 192.168.0.1:2200
jlinkels
So tunneling might be my answer, so I can use the physical machine as a proxy to the virtual machine on it.
By the way, winscp is a file manager on windows where you can easily download files through ssh (that's why it's called winscp). It provides a graphical interface which can be slightly better than using the terminal.
L.E. I used tunneling and it worked like a charm... Thanks for the information
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.