D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Wife's computer

 

On 09/02/2020 12:00, Neil wrote:
> On 08/02/2020 16:12, mr meowski wrote:
>>
> Well, lots of information and help there. My first reaction was to run 
> for the hills. However, that will not help so ....
> 
> I have a desktop computer. Wife and daughter each have laptops. All 
> three are set up with MX 19.
> 
> I treat all three machines as quite separate and independent. Every year 
> MX Linux has a new version ready. This requires a full installation, not 
> an upgrade. So I take each computer separately, copy the necessary files 
> and folders (eg documents, pictures, profiles) from the current version 
> on to an external HD. Then, on each machine, I run the new installation, 
> copy over the above folders and files, install any extra programs that 
> aren't automatically included with the install and away we go. Never had 
> any problems with that.
> 
> I can see that in this case each machine is treated as a single, stand 
> alone, computer. This  time I am talking about adding a second user. 
> Perhaps this will make a difference.
> 
> Meanwhile, I will do some research into SSH, since I have no knowledge 
> about it at the moment. But, are you really saying that, because this 
> time it will be a second user on to the laptop, that I could have 
> problems, whereas, previously, on each machine with just the one user it 
> was all fine?


Researching SSH will probably be a little bit overwhelming to a new user 
to be honest - even the basic introductions tend to go a bit overboard 
with introducing it's galaxy of features and jumping into keys, 
ssh-agents, forwarding and so on. I did look for a really nice "SSH 101" 
for you but didn't have much luck which was a bit of a surprise. The 
good news is that like most UNIX tools, it starts off being really 
simple and quick to grasp but you can (optionally) spend the rest of 
your life learning it's arcane invocations and becoming a master. Like 
chess or something I guess. You really only do want it for it's most 
essential use case luckily, which *is* nice and simple. Don't let it be 
too daunting or it will put you off.

At it's most simple (and how nearly everyone, including me, uses it 99% 
of the time), SSH gives you one thing: a good old shell where you can 
type commands into the computer to interact with and ask it to do stuff 
for you. So far so good, just like opening your terminal program of 
choice on a PC you're sat in front of. SSH adds a super power - you can 
open a shell over a network _on a different computer_. That's it 
basically. Don't worry about all the other fancy stuff it can do, that's 
a pretty immense thing to have no matter what else! The connection is 
secure and encrypted as well (like a modern version of the venerable 
telnet program which does the same thing, but without any security to 
speak of) so you can even use SSH to connect to a remote machine and get 
a shell across hostile or untrusted networks like the internet.

Make sense? SSH gives you secure access to other machines remotely, most 
normally so you can login and get a shell up to do "stuff".

To get started, choose your favourite machine - probably your Desktop 
I'd imagine - and install it. MX Linux is a bit weird to be honest (I 
once installed it in a VM out of curiosity to see why you liked it so 
much - I wasn't impressed but that doesn't mean anything of course)
but it's still Debian under the hood so everything is there in the 
standard repos. There are two parts to modern SSH installs - the SSH 
client which is normally installed on _every_ Linux system ever by 
default and the SSH server which isn't usually installed by default on 
most end-user type distros, Debian included. The server is the bit that 
listens for incoming SSH connections from other machines (obviously) and 
the client is the bit you use to connect to the SSH servers.

So for MX Linux (and any Debian variant I've ever used) to install:

sudo apt install openssh* -y

The wildcard instructs your machine to install both parts and some other 
little helper bits that you might as well have. At this stage you've got 
the tools but the server component isn't usually activated and actually 
running: it's a service and a critical one at that, so normally requires 
an extra step to turn it on (although Debian has the opposite policy to 
Arch for example, which will never activate services just because you 
installed them - Debian usually will activate them).

This brings us to an unfortunate point so I'm going to whisper it.

systemd

In my understanding, MX Linux ships with a minimal systemd-shim 
installed but not necessarily doing anything and for "reasons" prefers 
the old sysvinit system. Treading carefully I shall avoid commenting on 
this but trust me, it's lucky you can't see the face I'm making as I 
type this (I also just remembered why my MX Linux VM lasted barely 5 
minutes before heading straight to /dev/null).

Never mind though, I can still remember how to use sysvinit to start a 
service so you want to do this next:

sudo service sshd status # check if it's running yet
sudo service sshd start  # start up the ssh-server component

To enable or disable the ssh-server service you can do this (later):

sudo chkconfig sshd on   # enable the ssh-server permanently
sudo chkconfig sshd off  # in case you want to turn it off permanently

And at this point you've got a fully working SSH setup on your chosen 
machine. You can test it - rather counter-intuitively - on the same 
machine ignoring the network part entirely by doing this:

ssh localhost

You will be greeted with a yes/no question about accepting a key (say 
yes) and asked for your password: because we haven't specified otherwise 
the ssh-client will have connected to the local ssh-server with your 
current username, presumably "neil", so when it asks for your password 
(it will also show the account name you're connecting with) type it in 
and ta da, you have a secure remote networked SSH login. Now you just 
have a shell as per usual so type some commands and leave as per usual 
with "logout" when you're done, which'll exit the session and drop you 
back at your original shell again. That's it basically.

The magic stuff happens when you start extending it. So "ssh localhost" 
is pretty useless really but if you grab another PC, say one of the 
laptops, it starts showing it's power. After making sure you know the IP 
address and/or hostname of the computer you've just installed the 
ssh-server on you can open a shell on the computer #2 and issue:

ssh 192.168.0.5 # if you want to connect to it by IP address
ssh neilmainpc  # if you want to connect to it by hostname

The same thing will happen - accept the initial key (this is a one-off 
that happens on first connection only) and enter the password. Now 
you're logged in remotely and securely from computer #2 to computer #1. 
_This_ is what SSH is for in it's most basic (and useful form). Run some 
commands (htop is always nice to see some pretty status things running) 
and then exit when you're ready. That's it, SSH 101 I guess. To start 
with you'd want to keep things basic but you'll also need before long to 
SSH in as a different user (it's not a bad idea to specify this anyway) 
like so:

ssh neil@neilmainpc # if you wanted to connect from a shell running on 
Pam's user account on one of the laptops to your account on the PC.

Your next job would probably be to install SSH (client _and_ server 
parts) on all three systems you have and enable the server daemon part 
to run permanently. Use ssh to login and logout of each remotely to test 
it's working. Eventually you'll get to the point where you can for fun 
and no profit circle through all systems in a loop and come back to 
where you were in the first place.

Start on desktop PC:

ssh neil@neilslaptop # now logged in to laptop #1
ssh neil@pamslaptp # now logged in to laptop #2
ssh neil@neilmainpc # full circle completed, you're back at the PC you 
started on

Exit from each shell in turn and you'll be backed out one by one until 
your $SHLVL returns to normal.

At this point you'd have done more productive stuff than half the admins 
I work with.

Speaking of which I should probably get back to working instead of doing 
this, no Sunday off for this poor comrade.

As ever ask if you have questions, I'll feel like I'll have done 
something useful if this helps anyone get over the bump and start using 
SSH properly.

Cheers



-- 
The Mailing List for the Devon & Cornwall LUG
https://mailman.dcglug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq