Skip to content

VM and Container Shell Access with vsh

The vsh command in the ChromeOS Shell provides a powerful interface for connecting to shells within virtual machines (VMs) or containers hosted inside VMs. This is particularly useful for managing Linux environments, debugging containerized applications, and directly interacting with system internals.

Usage

vsh <vm_name> [<container_name>]

Parameters

  • <vm_name>: The name of the virtual machine to connect to.
  • <container_name> (optional): The name of the container inside the specified VM. If omitted, the command connects to the VM's default shell.

Examples

1. Connect to a VM

vsh termina

This connects to the termina VM's default shell. The termina VM is commonly used for running Linux applications on ChromeOS.

2. Connect to a Container Within a VM

vsh termina penguin

This connects to the penguin container within the termina VM. The penguin container is the default Linux container available on ChromeOS devices.

3. List Available VMs

Before connecting, you can list running VMs with:

vmc list

4. Use vsh for Debugging

vsh termina
# Run commands to troubleshoot Linux apps or services

Advanced Options

While vsh itself has no additional flags, you can enhance its functionality by combining it with commands like:

  • vmc create: Create a new VM.
  • vmc start: Start a VM before connecting.
  • vmc stop: Stop a VM when troubleshooting is complete.

Additional Information

  • Supported VMs and Containers: The vsh command works primarily with termina VMs and their containers. Additional configurations may be required for custom VMs.
  • Use Cases: Suitable for:
  • Running Linux-based applications.
  • Managing development environments.
  • Debugging network or system-level issues inside containers.

Best Practices

  1. Verify VM and Container Availability
  2. Use vmc list to check if the target VM is running.
  3. Ensure containers inside the VM are set up correctly.

  4. Secure Your Environment

  5. Ensure that VMs and containers have appropriate access controls.
  6. Use encrypted channels and limit permissions when necessary.

  7. Perform Regular Maintenance

  8. Regularly update VMs and containers to avoid security vulnerabilities.
  9. Use tools like apt or dnf within containers for package management.

  10. Use for Debugging and Configuration

  11. vsh provides direct shell access, making it ideal for debugging, configuration, and advanced system management tasks.

The vsh command is an indispensable tool for developers and power users working with ChromeOS's virtualized environments. It enables direct and efficient management of both VMs and containers, facilitating advanced troubleshooting and application development workflows.