Scheduled starting and stopping of the instance¶
Starting and stopping of the instance can be managed using the following instruction:
Install c2-ec2 utility on Windows or Linux machine to be used for management. This can be either a cloud-based VM or any other computer with Internet access. Installation process is described in CROC Cloud API Client paragraph.
Download API settings Open CROC Cloud management console at https://console.cloud.croc.ru/, click Settings link in the top right corner, and then click Download API settings
Change one line in these settings:
export C2_PROJECT="your project ID here". Put your project ID in the quotation marks. You can view it on the cloud management console at https://console.cloud.croc.ru/
You will need to export API access settings to the machine, which will start and stop the instance.
Use the following commands (also performed on the machine used to start/stop the instance) to start/stop the instance:
c2-ec2 StartInstances InstanceId.1 <instance_id> InstanceId.2 <instance_id> c2-ec2 StopInstances InstanceId.1 <instance_id> InstanceId.2 <instance_id>
The schedule is set using a task planner (such as crond in Linux).
See more detailed description of using c2-ec2 utility here: Supported API
Adding public SSH key in Linux¶
Follow the instruction below to add public key in Linux distribution:
Determine a file, in which public keys are stored in the system by executing the following command:
$ cat /etc/ssh/sshd_config | grep -i authorizedkeysfile AuthorizedKeysFile .ssh/authorized_keys
In home directory, create a subdirectory with a file in it if they do not exist (from command output at clause 1 - this is .ssh directory where the authorized_keys file is stored).
The .ssh directory and authorized_keys file should belong to user who will log in to the system (if the directory is created by a superuser then root will be its owner). To change the directory owner, use sudo chown -R ec2-user command:ec2-user /home/<username>/.ssh/
Use a text editor (vim, nano, etc.) to add public key content to the authorized_keys file (if another public key is already stored there, do not delete it; instead, add new one to the file. This will let you use two different private keys to log in to the system using ssh). An example of public key is shown below:
Public key shall be a continuous text without any spaces or line breaks.
After a new public key is added, you have to restart sshd:
For systems running SysVinit (CentOS 6):
sudo /etc/init.d/sshd restart
For systems running Systemd (CentOS 7):
sudo systemctl restart sshd
Correcting the resetting time error in Windows¶
To solve the time problem, you have to edit Windows registry so that it accepts time from BIOS as UTC:
Open Windows registry (Win+R -> regedit -> Enter)
DWORD, name it
RealTimeIsUniversal, and set value to
Reboot your instance
Advanced file storage management features¶
The s3cmd utility provides advanced features. Follow the steps below to install and set it up in CentOS 6.
Before installation, you have to obtain the API access settings on Cloud management console: https://console.cloud.croc.ru. Click Settings, then click “Download API settings”.
# cd /etc/yum.repos.d # wget http://s3tools.org/repo/RHEL_6/s3tools.repo # yum -y install s3cmd
Then you have to configure s3cmd (secret and secret key can be obtained from API access settings):
# s3cmd --configure Enter new values or accept defaults in brackets with Enter. Refer to user manual for detailed description of all options. Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables. Access Key: <имя проекта в облаке КРОК>:<Учётная запись в облаке КРОК> Secret Key: XXXXXXXXXXXXXXXXXXXXXX Default Region [US]: Encryption password is used to protect your files from reading by unauthorized persons while in transfer to S3 Encryption password: Path to GPG program [/usr/bin/gpg]: When using secure HTTPS protocol all communication with Amazon S3 servers is protected from 3rd party eavesdropping. This method is slower than plain HTTP, and can only be proxied with Python 2.7 or newer Use HTTPS protocol [No]: yes New settings: Access Key: <имя проекта в облаке КРОК>:<Учётная запись в облаке КРОК> Secret Key: XXXXXXXXXXXXXXXXXXXXXX Default Region: US Encryption password: Path to GPG program: /usr/bin/gpg Use HTTPS protocol: True HTTP Proxy server name: HTTP Proxy server port: 0 Test access with supplied credentials? [Y/n] y Save settings? [y/N] y
Then edit /root/.s3cfg configuration file:
host_base = storage.cloud.croc.ru host_bucket = %(bucket)s.storage.cloud.croc.ru signature_v2 = True
Now you can use s3cmd utility. Enter s3cmd –help command to learn how to use the utility
Allocating multiple Public IP addresses to single instance¶
Follow the below instructions to associate several Public IP addresses with single instance:
Select the subnet where the instance exists.
Select Private addresses tab.
Click Allocate address.
In a window that opens, select your desired options. Select Particular address, fill in the Address field and confirm the address by clicking Allocate address
The address should be Allocated in the same subnet where the instance exists. If you attempt to Allocate address, which is already Allocated to instance or belongs to other subnet, then error message will appear. The addresses ending with 1 or 255 cannot be Allocated either.
Open Address section, select shared Public address, and click Allocate address.
In a window that opens, select Allocate to Private Address option, enter Private address Allocated at step 4, and click Allocate address.
Then allocate this Private address as the second address of the interface in the operating system. An example below shows how to do this in Windows:
Start -> Control Panel -> Network and Internet -> Network and Sharing Center -> Change Adapter Settings.
Select Local network connection, right-click it and select Properties.
Select Internet Protocol version 4 (TCP/IPv4) and click Properties
In a window that opens, select Use the Following IP Address and click More…
In a window that opens, enter private address, which was Allocated by cloud DHCP server when creating the Instance, and the new one, which was Allocated at step 4. To view the current local address, use the following command: ipconfig (WIN+R->cmd->ipconfig) or open CROC Cloud management console https://console.cloud.croc.ru by clicking the instance ID.
When Allocating addresses manually, please note that 255.255.255.0 mask and a gateway with the last octet of the address with a value of 1 are used. For example, address 10.70.120.4 will have 10.70.120.1 as default gateway. Configuration example is shown below:
Now the instance will be shared at the additional Public IP address.
Adding SSH public key in Putty¶
Putty uses its own format for keys (.ppk). To use a third-party private key in Putty, you have to convert it to puttygen first:
Open PuTTY Key Generator application and select Conversions-> Import key
In a window that opens, select private key (usually it is in OpenSSH format and has the name .private)
After selecting, the window will be filled with the data from the key.
In this window you can leave a comment in the Key Comment line. In addition, you need to add a password to the private key in Key Passphrase and Confirm Passphrase lines.
Click Save Private Key to save the private key in the format acceptable by PuTTY.
If the same public key is used on multiple severs then you do not need to store private key on each server in order to attach to another server. You can use Pagent (PuTTY authentication agent) for this purpose. To add a key to Pagent:
Run pagent.exe. After startup, the program icon will appear in the system tray.
Double-click the icon in the system tray to manage keys.
In a window that opens, click Add Key and select private key in .ppk format. If the key has a password, enter it in the dialog when adding the key.
Alternatively, you can use the following feature to add a private key to Pagent easier:
- Create a shortcut for Pagent software
- Right-click the shortcut and select Properties
- In the Target field add space and add complete path to the private key in .ppk format
When you open this shortcut next time, private key will be automatically added to Pagent.
To use Pagent in PuTTY:
- Run putty.exe
- Select Attachment->SSH->Auth
- Check Allow Agent Forwarding box on this tab
- Open Session tab, select Default Settings, and click Save
Now, when a new attachment is created, its settings will include the use of Pageant for key transmission. The use of Pagent can be avoided if you select Browse instead of Allow Agent Forwarding on step 3 and select a private key to be used for attaching to the instance via ssh.
Instance migration to CROC Cloud¶
CROC Cloud Platform uses KVM hypervisor. So, before migration, please make sure that virtio drivers are installed and operating system supports using virtio controller. You can start the instance in CROC Cloud even if drivers are not installed, however, when using Volumes and network, the instance will show lower performance than with drivers installed.
If operating system supports virtio controller then install virtio driver to use Volumes and network.
Download Volumes from your virtualization platform
Convert Snapshots to qcow2 format using qemu-img utility. Below is a sample command for conversion from vmdk format:
qemu-img convert -f vmdk -O qcow2 -p <image_name>.vmdk <image_name>.qcow2
Upload Snapshots to CROC Cloud file storage. Steps to take:
- Open CROC Cloud management console at https://console.cloud.croc.ru/
- Open File Storage tab
- If you do not have a storage, click Create Storage, allocate a name, and confirm the creation
- Select a storage
- Click Upload File
- Repeat the upload procedure for all Volumes
Select the uploaded Snapshots one by one
Click Create Snapshot
When all Snapshots are created, open Console tab
Open Templates section
Click Create Template
In a window that opens, click Add Volume to add Volumes for the template
Add Snapshots created at step 6, one by one
Position your Volumes so that the root device is the first in the list
If your instance does not have virtio drivers, check Revoke Optimization box
Enter template description and click Create Template
Now you can deploy the instance from this template.
Instruction for creating Windows Server 2012 R2 DC virtual machine¶
To create a Windows Server 2012 R2 Datacenter virtual machine:
Log in to CROC Cloud console at https://console.cloud.croc.ru/
To create instances, at least one virtual network should be created. To create it, click Create Network, set network’s IP address in CIDR notation, and confirm the network creation. If a virtual network is already created, then proceed to the next step.
Open Instances tab.
Click New Instance. In a window that opens, select win2k12R2DC and click Next.
Select the desired Instance Type. For Windows, selecting an instance type with at least 2 GB RAM is recommended. You can also set additional options: Virtualization Type, Placement Group, Cluster, Allocate Public address, High Availability, Terminate on instance stopped, and Monitoring. Then click Start New Instance.
Then click ID of the instance. In a window that opens, click Remote Console.
Select the desired options and click Next.
Read the license agreement and click I accept.
Enter the administrator password, which will be used for logging in to the system. Then click Finish
To log in to the system, press Ctrl+Alt+Delete. This key combination can be transferred to the operating system by clicking a marked button in the top right corner of CROC Cloud remote console.
To log in to the system, enter the password, which was set at previous step, and press Enter.
Windows Server 2012 R2 Datacenter virtual machine is now created.
To access virtual machines using RDP, you need to set up the rule in the security group. Open your security group, click Ingress rules, and then click Add rule. In a window that opens, set protocol to tcp. Then specify set address range (CIDR notation is used: to add a single host, set ip_address/32, to add a subnet, use a smaller mask) and set port to 3389, and click Add rule.