Use the Linux Command Line to manage DigitalOcean VPS water drops

Source: Internet
Author: User
Tags cloud vps vps linux mint

Use the Linux Command Line to manage DigitalOcean VPS water drops

DigitalOcean is the most popular newborn in the cloud VPS host market. Although it does not provide integrated services like Amazon, DigitalOcean is positioned for small and medium-sized enterprises and developers and has become a strong competitor of the best cloud VPS Service Based on Linux, this is all due to their competitive prices and user-friendly management interfaces.

Whenever you need a network-oriented server for your personal project, you can start a "water drop" (nickname of the VPS instance in DigitalOcean) at full speed ), you can also kill it when you don't need it. There's no need to burn your wallet to keep your VPS running. Although DigitalOcean's network-based management interface is very efficient, it still provides a drop-down management tool based on the command line interface, called tugboat, for those command line interfaces. Thanks to this command line tool, all complex water drop management tasks can be simply converted into a script.

In this article, I plan to explain how to use tugboat to manage DigitalOcean water drops from the command line.

Install tugboat on Linux

Install tugboat On Debian, Ubuntu, or Linux Mint:

  1. $ Sudo apt-get install ruby-dev
  2. $ Sudo gem install tugboat

Install tugboat on Fedora:

  1. $ Sudo yum install ruby-devel
  2. $ Sudo gem install tugboat

To install tugboat on CentOS, first install or upgrade to the latest Ruby version, because in CentOS 6.5 and earlier versions, the default Ruby version does not meet the minimum version required by Tugboat (version 1.9 and later ). After Ruby 1.9 and later are installed, install tugboat as follows.

  1. $ Sudo gem install tugboat
Configuration for the first use of tugboat

After the installation is complete, configure it once, including authorizing tugboat to access the DigitalOcean account.

Go to https://cloud.digitalocean.com/api_accessand create a new API to record the customer ID and API secret.

Run the following command to start the authorization process:

  1. $ Tugboat authorize

Enter the customer ID and API key when prompted. It will ask several other questions. Currently, you can accept the default answer. We will customize the default settings later.

Now, let's customize the default water drop settings to reflect your typical usage. To do this, first check the available settings (such as available images, regions, and sizes) provided by the Water Drop ).

Run the following command to list available image drops. Select a default image and record the related ID.

  1. $ Tugboat images -- global

Similarly, select a default geographic location from the available region:

  1. $ Tugboat regions

At the same time, select a default water drop size from the available RAM size:

  1. $ Tugboat sizes

Now, place your default options in ~ /. Tugboat. For example, I have customized the default settings here: the region is in New York, the system is Ubuntu 14.04, and the memory is 512 MB. If you want to enable SSH Through key verification and set "ssh_user" to root, I will talk about it soon.

  1. $ Vi ~ /. Tugboat
  1. ---
  2. Authentication:
  3. Client_key: XXXXXXXXXXXXXXXXXXX
  4. Api_key: XXXXXXXXXXXXXXXXXXXX
  5. Ssh:
  6. Ssh_user: root
  7. Ssh_key_path:/home/dev/. ssh/id_rsa
  8. Ssh_port: '22'
  9. Defaults:
  10. Region: '4'
  11. Image: '20140901'
  12. Size: '66'
  13. Ssh_key :''
  14. Private_networking: 'false'
  15. Backups_enabled: 'false'
Create and add an SSH key to DigitalOcean

To access a water drop instance, a secure method is to connect to the instance through SSH key verification.

In fact, you can use DigitalOcean to register an SSH public key and automatically enable key verification for your water drop. The following shows how to do this.

First, generate a public/private key pair (if you do not have one ).

  1. $ Ssh-keygen-t rsa-C "your@emailaddress.com"

Assume that the generated key pair is from ~ /. Ssh/id_rsa (Private Key) and ~ /. Ssh/id_rsa.pub (Public Key). upload your public key. The command is as follows:

  1. $ Tugboat add-key [name-of-your-key]

You can name your key (for example, "my-default-key "). When prompted, enter the Public Key Path (for example,/home/user/. ssh/id_rsa.pub ). After the key is uploaded, run the following command to verify that the key is correctly added:

  1. $ Tugboat keys

The key should also appear on the DigitalOcean SSH key page. If you want the key to be automatically used in the Water Drop, add the key ID ~ /. Tugboat.

  1. Ssh_key: '123'
Basic usage of Tugboat

The basic usage of the tugboat command line is listed here.

  1. Use the default settings to create a new water drop.

    1. $ Tugboat create
  2. Lists All active water drops.

    1. $ Tugboat droplets
  3. Displays the information of water drops.

    1. $ Tugboat info

  1. Close the Water Drop and remove the image.

    1. $ Tugboat destroy
  2. Close the water drop, but keep the image

    1. $ Tugboat halt
  3. Create a snapshot for the Water Drop. The water drop must be closed first.

    1. $ Tugboat snapshot
  4. Adjust the water drop size (increase or decrease the RAM size). The water drop must be disabled first.

    1. $ Tugboat resize-s

If you want to know more options for a specific command, run:

  1. $ Tugboat help <command>

Troubleshooting
  1. When I run the tugboat command, the following error occurs.

    1. /Usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 31: in 'gem _ original_require ': /usr/lib/ruby/gems/1.8/gems/tugboat-0.2.0/lib/tugboat/cli. rb: 12: syntax error, unexpected ':', expecting kEND (SyntaxError)

    Tugboat requires Ruby 1.9 and later. You need to upgrade Ruby to solve this problem. For CentOS, refer to this tutorial

  2. The following error occurs when I try to install Tugboat using gem.

    1. /Usr/local/share/ruby/site_ruby/rubygems/core_ext/kernel_require.rb: 55: in 'require ': cannot load such file -- json/pure (LoadError)

Install the following gem to fix the problem.

  1. $ Sudo gem install json_pure

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.