Now you'll soon come across command line editors in Linux, and
these are the sorts of things people either love or they hate, and
they're certainly not going to agree with you and your choice of
editor. It's very much personal.
We're going to be going through and taking a look at how we can
install some software on our Alma Linux 8 system.
So we've seen very quickly the use of vi where there is vi improved.
So we're putting this onto our system.
We're also putting on the nano editor. For later though, we're also
adding in rsync to look at how we can go through and copy to remote
systems and using git‑core where we're then putting on the tools that we
can use for setting up and managing Git repos. When we use nano, nano is
a relatively simple editor.
It's not necessarily as powerful as some other editors,
but it has a relatively short learning curve and has a
very simple menuing structure.
We should be able to see that if we needed to go through and say
search for some text to edit, we could use Ctrl+W to then go through
and search for the text that we want to edit.
We can do the same thing within our vim text editor. Here, in both
of these instances, we're editing our sshd_config file, and we're
searching for password authentication.
I can just use /Password, and my search will actually be activated as I
start typing characters after the forward slash. Now just imagine this
though, being able to edit a file without having to go into the interactive
editor. It's almost a dream, and it puts us where we want to be in
automating our edit in a DevOps role.
If we go through and check the current configuration of
our SSH daemon, on the Ubuntu system, password‑based authentication is disabled.
We want password authentication via the SSH daemon to be enabled. So we can
go through and edit this either using our ordinary editors such as nano or
vim, but we could also go through and edit it directly from the command line
with sed without having any interaction.
We're using sed and uppercase E for an enhanced regular expression that allows
me to use the parentheses, ‑i for an inplace edit. The s within the string
that we pass through to sed is then saying substitute, and the text that we
want to look for to substitute is, then (PasswordAuthentication) no. The
parentheses allow me to use groups, so I can then reference the replacement
text being the first group,
i.e. PasswordAuthentication, and configuring it to be yes.
We then reference our file, and the edit is made. And I say
the nice thing about this,
we could build this into a script, and it would then execute without any
interaction from ourselves as an operator. Having made the edit,
we can go through and restart our SSH daemon. Let's say the idea
here is that we're working on the Ubuntu system, and we want to
enable password‑based authentication,
and we're going to be using that when we start looking at remotely
copying files. We can copy files that we create from our Alma Linux system through to our Ubuntu system.