singlefabric
AI DevelopmentContainer Instances

SSH Access to Container Instances

A guide to enabling and accessing SSH for container instances, including prerequisites, setup procedures, and key generation.

Prerequisites

  1. The container instance has been created successfully and the status is running.
  2. The local host has generated an SSH key pair. If not, refer to the section Generate SSH Key Pair.

Procedure

  1. View and Record SSH Public Key

    • For Windows systems, the SSH public key file is located at c:\user\<user_name>\.ssh\id_rsa.pub.
    • For Linux or macOS, execute cat ~/.ssh/id_rsa.pub to view the public key.
  2. Log in Using Jupyter

    • Access the container instance using Jupyter.
  3. Install openssh-server Service

    • Open the terminal in the container instance and run:
      apt-get update && apt install openssh-server
  4. Verify Installation

    • Check the SSH process:
      ps -e | grep ssh
    • Verify the installation package:
      dpkg -l | grep ssh
  5. Start the openssh-server Service

    • Run:
      service ssh start
  6. Check the Service Status

    • Verify the service is running:
      service ssh status
  7. Ensure SSH Path Exists

    • Run:
      mkdir ~/.ssh
  8. Add Public Key to authorized_keys

    • Append the local host's SSH public key to the container instance:
      echo "<public-key-content>" >> ~/.ssh/authorized_keys
    • Verify the public key:
      cat ~/.ssh/authorized_keys
  9. Copy SSH Command

    • From the container instance list page, click More Actions and select Copy SSH Command.
  10. Access the Container Instance via SSH

    • Open the terminal on the local host and use the copied SSH command.
  11. Install Daemons to Prevent SSH Disconnection

    • Run:
      apt-get update && apt-get install -y screen && apt install tmux

Appendix

Generate SSH Key Pair

  1. Check for Existing SSH Key

    • On Windows: c:\user\<user_name>\.ssh\id_rsa.pub
    • On Linux/macOS: ~/.ssh/id_rsa.pub
  2. Generate New SSH Key

    • If no SSH key exists, run:
      ssh-keygen
    • Press Enter to confirm default settings during the setup.
  3. View and Copy Public Key

    • Navigate to the SSH key directory and run:
      cat id_rsa.pub

On this page