Setup Linux VM with SFTP, Guide for @msdev

This article will quickly shows, in particular for #msdev who’re not familiar with Linux, how to set up a 32 bit Fedora VM with VirtualBox, and setup a SFTP server, then connect from Filezilla client from Windows machine hosting the Fedora VM.

STEP 1. Create Linux VM on VirtualBox. First, download vdi/vmdk image of Linux operating system. Google for “vdi vmdk Ubuntu” for example. Make sure you download an x64 image with username/pwd specified! Similar for SuSE, Fedora …etc

Ubuntu x64

http://www.osboxes.org/ubuntu/                           (username: osboxes, pwd: osboxes.org)

Ubuntu-14.10_64bit.7z

Ubuntu_12.04-64bit.7z

http://imagesvm.sourceforge.net/                        (username: vuser, pwd: vuser)

ubuntu-12.04-lts-x64-en.vdi.bz2

ubuntu-12.04.2-lts-server-x64-en-2tb.7z

Fedora x86

http://cable2.cs.ucdavis.edu/FedoraVM.rar        (username: root, pwd: Pwl!ghsnts.)

http://virtualboxes.org/images/

This version has Desktop pre-installed.

    Link: https://sourceforge.net/projects/virtualboximage/files/Fedora/17/Fedora-17-x86.7z
    Active user account(s) (username/password): root/reverse, fedora/reverse

 

Then follow these instructions.

http://csifdocs.cs.ucdavis.edu/documentation/archives/csif-fedora-on-a-virtual-machine

Don’t forget to check “Enable PAE/NX”

VirtualBox.EnablePAENX

And add a second Network Adapter if your first Adapter is configured in NAT mode.

VirtualBox.AddSecondNetworkAdapter

REF: http://ubuntuforums.org/showthread.php?t=1421927

“Please check the network settings of the Ubuntu VM. If it is configured in NAT mode (which is the default mode), then you will not be able to access your windows 7 host from your VM nor will you be able to access your VM from outside. If that is the case, you can add another virtual network adapter to the VM and configure the network mode as “Host-only Adapter”, so that it would get an IP address in the series of “192.168.56.xxx”. Similarly, host will also acquire a virtual NIC and IP address 192.168.56.1. Now you would be able to communicate between the VM and the host using the 192.168.56.x network.”

Please note that if you enabled this Host-only adapter, you wouldn’t be able to for example ping cnn.com

You wouldn’t be able to:

yum repolist all
yum info kernel

Instead you’d get error:

Error: Cannot retrieve repository metadata (repomd.xml) for repository: fedora. Please verify its path and try again

(Anyway, you’d still need to fix a few things for yum to work. REF: http://digitizor.com/2009/06/17/how-to-fix-the-cannot-retrieve-repository-metadata-repomd-xml-error-in-fedora-11)

Also, if you’re downloading the vm to test mono, try download a supported distribution (Ubuntu, SuSE for example):

http://www.codeproject.com/Articles/9407/Introduction-to-Mono-Your-first-Mono-app

http://www.mono-project.com/download/#download-lin

 

Also, Right-CTRL is default hotkey for VirtualBox to exit mouse capture.

*** The following steps for Fedora ***

STEP 2. Create user account:

groupadd sftp_users

useradd johndoe

passwd johndoe             (Then it will prompt you to enter the pwd for ‘johndoe’. For this exercise, pwd=SomePassw0rd)

usermod -G sftp_users johndoe

http://www.labtestproject.com/linuse/adding_user.html

STEP 3. Then config and start SFTP server like this:

cd /etc/ssh

vi sshd_config

Press INSERT to enter text in vi.

Press ESC when done. Then “:wq!” to save+exit

To set /home as root folder, modify “ChrootDirectory” setting using vi, then hit “wq!”:

ChrootDirectory /home

Also, comment out and add a line like below

#Subsystem sftp /usr/libexec/openssh/sftp-server

Subsystem sftp internal-sft

Then restart the service:

systemctl restart sshd.service

And try connect locally:

sftp johndoe@localhost

Then, try connect to VM from your Windows workstation hosting the VM? From VM command prompt, type ifconfig (not ipconfig) to identify IP address of your VM (2nd Network Adapter).

VirtualBox.ifconfigsf

Then from for example, Filezilla client:

VirtualBox.FilezillaClient

Happy Coding!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s