Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a production server off site and a development server as a virtualbox on my laptop.

My question is how do I setup virtualbox's network before booting the image so that I can SSH between the two?

(Google has a lot on this subject but it is usually people asking how they can ssh between the host and the client)

share|improve this question

migrated from stackoverflow.com Jun 2 '11 at 0:27

This question came from our site for professional and enthusiast programmers.

2 Answers 2

You set the networking adapter into bridged mode (virtual box settings). That's all.

If you want to be able to access your development server from the production server, you need to port-forward port 22 to your development computer/virtal box IP.

To access the file system on the production server, you can use scp to copy files back and forth. I wouldn't recommend it however, it's a pain in the ass.

I would recommend you sshfs.

The way sshfs works is, it mounts the remote file system in your local filesystem. Then you just open, edit, save, copy/paste files there, and sshfs does the scp data-transmitting stuff in the background.

Command:

sshfs theUserYouWantToLoginAs@ip.of.target.computer:/ /path/to/folder/where/you/want/to/mount/the/remote/filesystem

example:

sshfs root@74.125.77.99:/ /mnt/sshfs

PS: I would use ssh keys, not a password. Passwords are too weak.

To generate a key:

ssh-keygen -t rsa -b 4096

This generates id_rsa and id_rsa.pub
id_rsa.pub you echo into the authorized_keys file in the .ssh folder in the home directory of the ssh user on the target machine
example:

copy id_rsa.pub file to the target computer
cat ./id_rsa.pub >> /root/.ssh/authorized_keys
share|improve this answer
    
what happens if I need to pull files from the production server onto the development (VB) server? –  Sevenearths Jan 11 '11 at 15:42
    
I would mount the production server's file system as ssh file system. –  Quandary Jan 11 '11 at 21:27
    
Note that you can omit user@ from user@ip if the user on the target machine corresponds to the user you're currently logged in with on the development machine. –  Quandary Jan 11 '11 at 21:37
    
Maybe I should explain a bit more. –  Sevenearths Jan 11 '11 at 23:38
    
I tried the bridge route but I just got ssh: connection to host xxx.xxx.xxx.xxx port 22: Network unreachable. My setup is: router: 192.168.1.1 - host: 192.168.1.4 - guest: 192.168.1.5 (vb/dev) and I let through 22 for 192.168.1.5 on my router. What I find weird about all of this is I can still ssh from the host machine (192.168.1.4) to the production server –  Sevenearths Jan 11 '11 at 23:44

I found a way to ssh into the development server, but it wasn't with the command line so I don't know if this counts as an answer!

In my development (guest) OS, Cent OS, I can connect to my production server in the big wide world by going to:

Places > Connect to Server

and filling out the details as you would normally. (strangely when you select ssh it still asks you for the port you would like to use!?!)

Also. I don't know if this makes a difference but I entered the following into the host before booting the Cent OS image:

VBoxManage modifyvm "Cent OS 5.5" --natpf1 "guestssh,tcp,,22,,22"

recomended from here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.