ESX Virtualization

VMware ESXi, vSphere, VMware Backup, Hyper-V... how-to, videos....

Nakivo Backup and Replication - #1 Backup solution for Virtual, physical, cloud, NAS and SaaS

Menu
  • Certification
      • VCP-DCV vSphere 8
          • vcp2024-125.
        • Close
    • Close
  • VMware
    • Configuration Maximums
    • vSphere
      • vSphere 8.0
      • vSphere 7.0
      • vSphere 6.7
      • vSphere 6.5
      • vSphere 6.0
      • Close
    • VMworld
      • VMware EXPLORE 2024
      • VMware EXPLORE 2023
      • VMware EXPLORE 2022
      • VMworld 2019
      • VMworld 2018
      • VMworld 2017
      • VMworld 2016
      • VMworld 2015
      • VMworld 2014
      • VMworld 2013
      • VMworld 2012
      • VMworld 2011
      • Close
    • Close
  • Microsoft
    • Windows Server 2012
    • Windows Server 2016
    • Windows Server 2019
    • Close
  • Categories
    • Tips – VMware, Microsoft and General IT tips and definitions, What is this?, How this works?
    • Server Virtualization – VMware ESXi, ESXi Free Hypervizor, VMware vSphere Server Virtualization, VMware Cloud and Datacenter Virtualization
    • Backup – Virtualization Backup Solutions, VMware vSphere Backup and ESXi backup solutions.
    • Desktop Virtualization – Desktop Virtualization, VMware Workstation, VMware Fusion, VMware Horizon View, tips and tutorials
    • How To – ESXi Tutorials, IT and virtualization tutorials, VMware ESXi 4.x, ESXi 5.x and VMware vSphere. VMware Workstation and other IT tutorials.
    • Free – Free virtualization utilities, ESXi Free, Monitoring and free backup utilities for ESXi and Hyper-V. Free IT tools.
    • Videos – VMware Virtualization Videos, VMware ESXi Videos, ESXi 4.x, ESXi 5.x tips and videos.
    • Home Lab
    • Reviews – Virtualization Software and reviews, Disaster and backup recovery software reviews. Virtual infrastructure monitoring software review.
    • Close
  • Partners
    • NAKIVO
    • StarWind
    • Zerto
    • Xorux
    • Close
  • This Web
    • News
    • ESXi Lab
    • About
    • Advertise
    • Archives
    • Disclaimer
    • PDFs and Books
    • Close
  • Free
  • Privacy policy

How-to change default SSH port on ESXi 5 and make the change persistent after reboot

By Vladan SEGET | Last Updated: February 21, 2020

Shares

How-to change default SSH port on ESXi 5 and make it persistent after reboots.

If you want to keep SSH to your ESXi hosts, but want to change the default SSH port (22) to non default port, there is a way to do it. For example you don't wan to have SSH on 22 but on 2222.

How to do it? What's the requirements?

01. You'll have to create an XML file which needs to be placed on persistent storage or VMFS volume. (/vmfs/volumes/).

02. Copy the xml file there. The volume can laid on shared storage so it'll be accessible by all your hosts. In my case /vmfs/volumes/freenas/ssh

The content of the xml file has to be like this:

<ConfigRoot>
<service>
<id>SSH 2222</id>
<rule id = ‘0000'>
<direction>inbound</direction>
<protocol>tcp</protocol>
<porttype>dst</porttype>
<port>2222</port>
</rule>
<enabled>true</enabled>
<required>false</required>
</service>
</ConfigRoot>

03. Add these lines to the /etc/rc.local file:

cp location of xml file /etc/vmware/firewall
esxcli network firewall refresh

Where location of xml file is the location that the file was copied to in step 2.

Like this the new firewall configuration will be actively loaded and every time the host restarts it loads the custom firewall configuration.

04. Copy /etc/services to the storage (same location as the firewall rules are stored for example – my case).

How to configure ESXi 5 for different port on SSH

05. Edit the services file and change and change the port number for SSH.

06. Edit /etc/rc.local so the created files are copied back to host at boot time. Here is an example, those lines would be added at the end of the file:

#Copy the new firewall rule from vmfs place holder to file system
cp /vmfs/volumes/freenas/etc/ssh2222.xml  /etc/vmware/firewall/
#refresh firewall rules
esxcli network firewall refresh
#Copy the modified services file from vmfs place holder to file system
cp /vmfs/volumes/freenas/ssh/services /etc/services
#Restart inetd to get the changes
kill -HUP `cat /var/run/inetd.pid`

 

You'll have to reboot the host to validate the changes and test if everyting works.

Sources:

VMware KB User defined xml firewall configurations are not persistent across ESXi host reboots

VMware KB Changing the port used by SSH on an ESXi 5.0 host

 

Shares
Vote !

| Filed Under: How To

About Vladan SEGET

This website is maintained by Vladan SEGET. Vladan is as an Independent consultant, professional blogger, vExpert x16, Veeam Vanguard x9, VCAP-DCA/DCD, ESX Virtualization site has started as a simple bookmarking site, but quickly found a large following of readers and subscribers.

Connect on: Facebook. Feel free to network via Twitter @vladan.

Comments

  1. DrEmmettBrown says

    January 17, 2018 at 10:42 pm

    Dear Vlatan ,

    Thank you for your post. let me fix ( maybe add) one thing.

    when you connect to your esxi with ssh you can’t edit /etc/services because it’s readonly.

    so you can change your startup script with this

    #Copy the new firewall rule from vmfs place holder to file system
    cp /vmfs/volumes/freenas/etc/ssh2222.xml /etc/vmware/firewall/
    #refresh firewall rules
    esxcli network firewall refresh
    #Copy the modified services file from vmfs place holder to file system

    #if we don’t delete /etc/services file it will stay same.. it’s ridiculous but true..but if we delete it #then it works.

    rm -rf /etc/services

    cp /vmfs/volumes/freenas/ssh/services /etc/services
    #Restart inetd to get the changes
    kill -HUP `cat /var/run/inetd.pid`

    Thanks

    • Vladan SEGET says

      January 18, 2018 at 10:29 am

      Oh, this is an old post. I don’t even know if it still applicable for ESXi 6.5. Thanks for your commend, thought.

Private Sponsors

Featured

  • Thinking about HCI? G2, an independent tech solutions peer review platform, has published its Winter 2023 Reports on Hyperconverged Infrastructure (HCI) Solutions.
  • Zerto: One Platform for Disaster Recovery, Backup & Cloud Mobility: Try FREE Hands-On Labs Today!
Click to Become a Sponsor

Most Recent

  • FREE version of StarWind VSAN vs Trial of Full version
  • Commvault’s Innovations at RSA Conference 2025 San Francisco
  • VMware ESXi FREE is FREE again!
  • Installation of StarWind VSAN Plugin for vSphere
  • Protect Mixed environments with Nakivo Physical Machine recovery (bare metal)
  • No more FREE licenses of VMware vSphere for vExperts – What’s your options?
  • Tails – Your Private OS on USB Stick
  • StarWind V2V Converter Now has CLI
  • Veeam VHR ISO v2 – 2025 Download and Install
  • Deployment OVA and Installation of Nakivo Backup and Replication for VMware

Get new posts by email:

 

 

 

 

Support us on Ko-Fi

 

 

Buy Me a Coffee at ko-fi.com

Sponsors

Free Trials

  • DC Scope for VMware vSphere – optimization, capacity planning, and cost management. Download FREE Trial Here.
  • Augmented Inline Deduplication, Altaro VM Backup v9 For #VMware and #Hyper-V – Grab your copy now download TRIAL.

VMware Engineer Jobs

VMware Engineer Jobs

YouTube

…

Find us on Facebook

ESX Virtualization

…

Copyright © 2025 ·Dynamik-Gen · Genesis Framework · Log in