Skip to content

SSH Directly to Guestshell on NX-OS

Guest Shell is an LXC container that runs on Nexus switches (if enabled). Typically this separate execution space is accessed from the NX-OS CLI by typing guestshell. This article shows how to enable SSH within the Guest Shell so you can SSH directly to it.

Create User in NX-OS

username cisco password 0 <password> role network-admin

Resize Guestshell

Disable the guestshell, resize resource allocations, re-enable guestshell.

# Disable guestshell to resize allocations
guestshell disable
y

# Resize guestshell allocations
guestshell resize cpu 10
guestshell resize mem 2048
guestshell resize rootfs 1024
guestshell enable

Set up SSHD Service

This assumes you're going use an IP address in the management VRF; e.g. mgmt0 interface IP address. Replace "management" in the ExecStart line with the appropriate VRF name if this is not the case.

sudo vi /usr/lib/systemd/system/sshd-management.service
[Unit]
Description=OpenSSH server daemon
After=network.target sshd-keygen.service
Wants=sshd-keygen.service

[Service]
EnvironmentFile=/etc/sysconfig/sshd
#ExecStartPre=/usr/sbin/sshd-keygen #NO LONGER VALID IN GUESTSHELL 4.0
ExecStart=/sbin/ip netns exec management /usr/sbin/sshd -f /etc/ssh/sshd-management_config -D $OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

Set up SSHD Config

sudo vi /etc/ssh/sshd-management_config
Port 2222
ListenAddress 0.0.0.0

Load & Start Service

sudo systemctl daemon-reload
sudo systemctl start sshd-management.service
sudo systemctl status sshd-management.service -l

# Enable the service to persist through reboots.
sudo systemctl enable sshd-management.service

Set up Authentication

Assign the guestshell "cisco" user the same password that was created in NX-OS.

sudo passwd cisco
sudo usermod -aG wheel

(Optional) Copy pubkey for passwordless login.

ssh-copy-id -i .ssh/id_ed25519.pub -p 2222 cisco@10.10.99.99

Comments