After installing Fedora Server 41 (DVD) on VirtualBox 7.1.4 using standard procedures, proceed with configuring the SSH server.
Configure the SSH Server
Install the OpenSSH Server Package
sudo dnf install openssh-server
Activate and Enable the SSH Service
Start the service and configure it to launch automatically at boot:
sudo systemctl start sshd
sudo systemctl enable sshd
Modify SSH Configuration Settings
The configuration file is located at /etc/ssh/sshd_config. Edit it with a text editor like vim or nano:
sudo vim /etc/ssh/sshd_config
Key configuration parameters include:
-
Customize SSH Port (optional):
Port 2222Replace
2222with any available port number. -
Prevent Root Login (recommended):
PermitRootLogin no -
Restrict User Access:
AllowUsers your_usernameSubstitute
your_usernamewith the permitted login account. -
Disable Password Authentication (recommended for key-based login):
If key authentication is not yet configured, password authentication can remain enabled:
PasswordAuthentication yes
Restart the SSH Daemon
Apply changes by restarting the SSH service:
sudo systemctl restart sshd
Adjust Firewall Rules
Ensure the firewall permits SSH connections:
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
For non-default ports, specify the new port explicitly:
sudo firewall-cmd --permanent --add-port=2222/tcp
sudo firewall-cmd --reload
Assign Static IP in VirtualBox
Set the virtual machine's network adapter to bridged mode and assign a static IP within the same subnet as the host system to maintain consistent connectivity:
sudo nmcli connection modify enp0s3 ipv4.method manual ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns 8.8.8.8
sudo nmcli connection reload
sudo ifconfig enp0s3 down
sudo ifconfig enp0s3 up
VS Code should now connect successfully via SSH. If it hangs during "initializing VS Code server", remove the remote server cache with rm -rf ~/.vscode-server, then reconnect.
Run VM Without GUI
To run the virtual machine without launching its display interface:
Create a desktop shortcut for the VM and modify its target path from:
"C:\Program Files\Oracle\VirtualBox\VirtualBoxVM.exe" --comment "Fedora Server" --startvm "{2d229ecf-4386-4768-a93f-682c45da8b35}"
to use headless execution instead:
"C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe" --comment "Fedora Server" --startvm "{2d229ecf-4386-4768-a93f-682c45da8b35}"