SSH using key-based authentication Generate SSH Key Pair on Host (if not already created): ssh-keygen -t rsa -b 2048 Follow the prompts to save the key pair. Copy Public Key to Container: ssh-copy-id
[email protected] : Replace username with your SSH user. Replace 192.168.1.x with the container’s IP address. Alternatively, manually copy the public key: cat ~/.ssh/ id_rsa.pub | ssh
[email protected] ' mkdir -p ~/.ssh && cat >> ~/.ssh/ authorized_keys ' Configure Key-Based Authentication in the Container: Edit SSH configuration to ensure key-based authentication is enabled: nano / etc /ssh/ sshd_config Ensure the following lines are set: PubkeyAuthentication yes AuthorizedKeysFile .ssh/ authorized_keys Restart SSH Service: systemctl restart ssh SSH into the Container Using Key: ssh - i ~/.ssh/ id_rsa
[email protected]