Enabling SSH access for Photon OS

For some users, whether you should or shouldn’t use SSH is a matter for debate. Rather than be hypocritical, I simply acknowledge that most admins will access Linux systems using SSH, and prefer to suggest that using strong passwords or passphrases and secure Management Networks is a more realistic approach to Linux administration.

By default, root access by SSH is disabled on Photon OS. In the following few steps, we will enable root access and log on to the Photon OS using Putty

For clarity, and because characters like : “ ( { are all found in Linux configurations files, I am going to surround individual keystrokes with brackets [ ], so the return key will be: [Del]

After you log-on to the VMRC of Photon OS type: ifconfig

The command ifconfig will reveal the DHCP IP address that your Photon OS VM was given if you built the VM on a NAT network using Workstation Pro, or if there is a DHCP server on the network where you built Photon OS.

Using vi

vi (VIM) is not everybody’s favorite text editor, but it is ubiquitous. You’ll find vi on all versions of the VCSA, on ESXi and on Photon OS. I will be very specific in the syntax of vi utilization, and hopefully you will become more comfortable with its use over time.

Enable SSH

Enter the command: vi /etc/ssh/sshd_config

vi /etc/ssh/sshd_config

You will need to use the [Up] or [Down] arrow keys on your computer to place the cursor at the beginning of the line that reads:

#PermitRootLogin prohibit-password

PermitRootLogin prohibit-password

Use your [Del] key 1 time, to remove the # comment from the beginning of the line. PermitRootLogin turns red when you remove the comment.

PermitRootLogin turns red

Use your [Right Arrow] 16 times to place the cursor right before the words: prohibit-password

prohibit-password

Press the [Del] key 17 times to remove the words: “prohibit-password”

Press the lowercase [a] key to enable editing in Insert After Mode

Type: yes

Make sure there is a space between PermitRootLogin and yes

You are currently in INSERT/EDIT mode

Press [Esc] to leave INSERT mode

Type [:] to enter command mode (this is the colon key, usually found next to the [Enter] key, engaged by pressing [Shift]+[:]

Enter [w] [q] to write and quit

Press [Enter]

Now type the command: systemctl restart sshd

And open Putty, or your favorite SSH client, followed by the IP of your Photon OS instance (that you observed in the beginning, when you typed ifconfig)

You will acknowledge the alert with: Yes

And proceed to connect with the username: root and the password you assigned

About: John Borhek

John Borhek is the CEO and Lead Solutions Architect at VMsources Group Inc. John has soup-to-nuts experience in Mission Critical Infrastructure, specializing in hyper-convergence and Cloud Computing, engaging with organizations all over the United States and throughout the Americas.


Leave a Reply

Your email address will not be published. Required fields are marked *