Clone a Cloud9 workspace into an SSH enabled setup - digital-ocean

My question concerns migrating a web app built in Flask to a Droplet.
I have built the app in a private workspace, using the Flask template in C9. Now it's been developed, I want to set up the app in a Digital Ocean droplet. To connect a brand new C9 SSH workspace to a droplet is fine; however, the SSH workspace by default does not have many of the dependencies (mySQL; Flask) and this is a major pain. I'm using a droplet with Ubuntu NodeJS 6.9.5 on 14.04.
Is there a way to have my existing private dev workspace cloned to an SSH workspace? It would be even better to have a single workspace maintained that syncs to the other, should I wish to take down the droplet for any reason.
Thanks.

Why can't you just image the disk, a digital copy of a working c9 to your new workplace, then use rsync to do increment sync.
rsync -azHAXxP -e 'ssh -p22' username#your-droplet-IP \
"dd if=/dev/sda of=myworking-droplet.iso bs=512 conv=noerror,sync"
Now that you have a full copy of working droplet as an image (.iso) file,
you can copy this to any hard disk of your choice and boot into it.
Image your Cloud9 into USB
If your C9 filesize is less than 30G, you can copy this into usb drive and maintain a locally bootable copy, that is you can image this unto any larger USB
and make it bootable, to achieve this do :
Mount USB of bigger size than size of your iso.
Check your mounted flash drive localtion with df -h, or lsblk -a
Image your iso file to usb with :
dd if=myworking-droplet of=/dev/sdb bs=512k conv=noerror,sync
Once finished, remove your drive, plug it into another PC,
change the boot order to USB Drive
and boot into your C9 locally
Sync Your Cloud9 workspace directory to another box
It gets better if you just want to sync your C9 workspace directory
over SSH connection to another box, use:
`rsync -azHAXxP -e 'ssh -p22' username#your-droplet-IP:/path/to/your/workspace .`
The above will clone your workspace directory over to your current box.
NOTE: The dot at the end of the command is necessary.
Mount your Cloud9 workspace to your local machine
Also you can mount your remote workspace file system to your local computer so you can make changes on
the fly and treat your droplet as local storage, so you can work and
access the same workspace locally without the need to login into your Cloud9
everytime you want to make changes or work on your project, to achieve this use:
Install SSHFS if not already installed with :
sudo apt-get install sshfs
Create a local directory in which to mount the droplet's file system.
sudo mkdir /mnt/mydroplet
Mount your droplet with:
sudo sshfs -o allow_other,defer_permissions \
root#xxx.xxx.xxx.xxx:/ /mnt/mydroplet
If your droplet is configured for login via ssh key authorization, use this:
`sudo sshfs -o allow_other,defer_permissions,IdentityFile=~/.ssh/id_rsa \
root#xxx.xxx.xxx.xxx:/ /mnt/mydroplet`
Now you can work with files on your droplet as if it were a physical device attached to your local machine.
Testing your mount from your local machine:
`cd /mnt/mydroplet`
Creat a test file
touch TestFile.php
Now login into you Clound9 and verify that you can access and modify the newly created file i.e TestFile.php
Now you can code locally, it immediately appears on your C9, or upload files from your local machine to your Cloud9 by copy file to your locally mounted directory.

Related

VM Debian Google Cloud Accounts cannot see other account's folder

I wanted to ask something regarding Debian Virtual Machine on Google Cloud. So I've set some configurations on my Compute Engine and on my laptop such that I can ssh to the VM from my laptop with ssh account1#IPAddress and now I'm logged in as account1#VM-name $ in my terminal. After doing so, I clone my own GitHub Repo to start my Node.js server (the Node.js server might be unimportant in this case, but the git clone is important to the story line). Then, I decided to disconnect from terminal and decided to do SSH-in-browser method. With that I'm logged in with my email, that is let's say account2#VM-name $. However, when I typed ls, the GitHub folder is not there. Is this normal with Debian VMs across cloud services such that different accounts cannot see other folders, or is there actually away to share the same files with different "ssh accounts"? Or maybe I should sudo git clone such that it is saved in the root folder in the VM?
Thanks a lot for the help!
when you logged using account1#vm-name and cloned your github repo it will be available in /home/account1 directory.
Now when you are logged in now with account2#vm and do ls , it will show details of /home/account2 and it is obvious nothing is there.
you can use below commands.
sudo cd /home/account1
ls

Clone a google cloud VM

I have google cloud VM with Ubuntu installed along with various services and libraries. I need to make a similar bootable VM with the same OS and all the data, libraries etc in the already configured VM. How do I clone the VM with these requirements?
I tried to create an image from the already existing VM and could not SSH into it.
So I retraced my installations step by step trying to figure out which step is breaking the image.
I created an Ubuntu(18.04) VM and used that to create an image. The instance I created using the image did allow me to SSH into.
Next installed Ubuntu desktop and xorg server and created an image after that. Using that image, I created a new VM and tried to SSH into it.
But unfortunately, the SSH connection could not be established. So I think it is these installations that are causing the error if it is not some sort of system error.
Below are the exact commands I ran to install these after creating an Ubuntu(18.04) VM:
sudo passwd username
sudo su -
passwd
apt update && apt upgrade -y
adduser username root
adduser username admin
adduser username sudo
apt-get install ubuntu-desktop -y
apt-get install xserver-xorg-video-dummy
nano /etc/X11/xorg.conf
and pasted the following into the .conf file
Section "Device"
Identifier "Configured Video Device"
Driver "dummy"
EndSection
Section "Monitor"
Identifier "Configured Monitor"
HorizSync 31.5-48.5
VertRefresh 50-70
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1600x900"
EndSubSection
EndSection
After this state, I created the image using which I could not instantiate a VM that I could SSH into.
Since you have your VM ready and running; backup your image as per this GCP document. Follow the guidelines before you begin the process which were mentioned in the document like updating Google cloud CLI setting default region and zone and for general image guidelines.
Few networking features may require guest operating system mode. You can also check how to export a custom image to cloud storage.
You can also consider the Snapshot Approach.
Follow this process in order to create the image exactly as the one you have already set up and you know is working correctly. As you may already know, this is a custom image so they are available only to your Cloud project. You can create a custom image from boot disks and other images if you would like also. Then, use the custom image to create an instance.
I will also suggest you to give a look at this document which would give you a deeper knowledge on the task.
Regards,
Just spin up a new container from a disk snapshot, if you need an exact copy. And if you cannot SSH, you may either not have a SSH public key provisioned, no external IP assigned, or :22 closed.
gcloud ssh always works. One can as well provision project-wide SSH keys, which all VM in the project will inherit then. The documentation below: About VM metadata explains this all in detail.
My personal favorite are rather startup scripts, which describe the configuration, instead of copying it.
And it's not so difficult to get started with these: cat ~/.bash_history > rocky8_startup.sh. In a software-defined data-center, it might make sense to use software-defined configurations (one simply cannot alternate the installation per VM instance, when starting with a disk snapshot).
xserver-xorg-video-dummy is questionable, because one can enable display device -but unless recording the screen, this driver might still suffice; eg. for VNC sessions.

How does one configure shared folders to automount for arch/manjaro linux VM in virtualbox?

I have a manjaro/arch virtual machine running in virtualbox with a windows 10 host. I have configured the shared folder I want to share in virtualbox as c:\tfs with the name tfs but it doesn't show up in the linux vm anywhere. I am able to mount it manually, but it won't auto-mount. I created the /media and /media/tfs folder in the VM, since it did not exist, and now the following command successfully manually mounts my folder sudo mount -t vboxsf tfs /media/tfs. How do I get the automount to work as intended without resorting to editing /etc/fstab?
It turns out that a few more steps are needed to configure the automount for shared folders of virtualbox. This tiny forum post was the key. You need to enable and start the virtualbox service vboxservice.service installed with the guest utils.
First ensure you have a folder /media, this is where it will try to mount your shared folders
Ensure that the guest utils are installed with sudo pacman -Q virtualbox-guest-utils
Enable service with sudo systemctl enable vboxservice.service
Start service with sudo systemctl start vboxservice.service
Reboot, I tried just logging out but reboot was necessary for me to start the service
Verify that your folder is now automounted in /media with sf_ prefix, mine is /media/sf_tfs
p.s. I also ran this command based on another post to add my username to the vboxsf group, although I'm not sure whether this one was necessary or not. sudo usermod -aG vboxsf brandon

mkdir: cannot create directory : Protocol error : Virtualbox Shared folder

I am trying to create folders and file in Virtualbox shared folder from Host to guest.
But i get this error mkdir: cannot create directory : Protocol error.
Below are steps i performed to share folder
1:My host OS is Ubuntu and my guest is Ubuntu.
2:I attached a share folder to virtualBox VM
Folder Path:/DR/vault/config
Folder:config selected automount and make permanent.
3:In Guest OS i installed virtualbox guest additions
4:I am trying to mount folder on /mount/config path
I added entry in guest's /etc/fstab as
/config /mount/config vboxsf rw,uid=1000,gid=1000 0 0
Path gets successfully mounted after Guest reboot also i can see the files created in /DR/vault/config(Guest) to /mount/config(Guest) but i cant create folder or file in /mount/config (Guest)
Please suggest if anything is missing or if there is any other way.
In my case, I had the drive full, clearing some space on the drive solved the issue.
I have found this is a problem with filename lengths on DOS hosts.
I have been using VirtualBox VMs as a form of containerised environment for deploying to a JBoss server, having experienced far too many problems with Windows environments for said technology.
I was using a shared-directory with my host machine as I was trying to keep the virtual machine lightweight (i.e. keeping IDEs in the host machine), then checking code into the shared directory for deployment with Maven. However, maven was giving some odd errors when the directory length grew to over 255 characters. Try looking at your file absolute path (type "pwd") and seeing if it's longer than 255.
I've resolved this problem with the following:
On the guest machine, add your user to vboxsf group: sudo adduser username vboxsf
Restart the host machine.
My host OS is Windows, my guest OS Ubuntu.
This might be an indication that the folder does not have the correct permissions on the Virtualbox host.
E.g. my headless Virtualbox server is running as "vbox" user, so I had to give that user write permissions on the host folder.
I had a similar issue, turns out that for me it was the number of folders or length of path name involved in mkdir.
typically I had :
mkdir -p /projects/bot/node_modules/webpack/node_modules/uglifyjs-webpack-plugin/node_modules/uglify-js/node_modules/yargs/node_modules/cliui/node_modules/center-align/node_modules/align-text/node_modules/kind-of/node_modules/is-buffer
Manually I could create up to the last part of the path but not the 'is-buffer' folder
I am working in vagrant and my projects folder is a shared VM folder, maybe/probably windows' max path length is the reason.

Clone an OpenVZ system to run locally

I have a VPS on an ISP which is using OpenVZ. I want to run my own image locally to test some services, but I can only download a tar backup of the filesystem.
Can I create a image and run it locally using the tar backup ? I'm on Windows 7. Maybe VMWare Player or Oracle VirtualBox can run this files ?
Yes, you can. You can install centos 6 and OpenVZ in a virtuall machine and create a container from the backup there. http://openvz.org/Quick_installation