Can't ssh into computer on my lan

Just trying to connect to another computer on my lan .
I install openssh on both computers.
Here is the message I am getting:

[demo@Manjaro ~]$ ssh -p 2222 demo@192.168.68.21
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ED25519 key sent by the remote host is
SHA256:aNdqE2oU1CKKcyUFiujnVitegfPGowh+pkwDmTIVHpo.
Please contact your system administrator.
Add correct host key in /home/demo/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/demo/.ssh/known_hosts:30
Host key for [192.168.68.21]:2222 has changed and you have requested strict checking.
Host key verification failed.

Not sure what to check for this issue.

This is the clue. I’ve had this happening to my computers too in the past, and deleting the file — in my case, there was only one entry in it anyway — solved it. The file was recreated on the next ssh login.

1 Like

You will need to remove the old key at line 30, first. If you did not generate the new key on the machine on your lan, then you have a problem.

2 Likes

That got me in now I want to set it up so I don’t have to use a password just have it exchange keys to connect.
I know I have to create a public key and sent to the machine.

If you don’t already know there are many articles on line, just search for something like set up ssh passwordless login

Can’t see to get past this error:

emo@Manjaro .ssh]$ sudo ssh-copy-id -p 2222 demo@192.168.68.21
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed:
/usr/bin/ssh-copy-id: ERROR: No identities found

What instructions did you follow?

How did you create your public key, and are you using port 22 or 2222, and is demo@<ipaddress the correct user on the server?

I created it like the instructions in the link.
ssh-keygen -t ed25519 -C “your_email@example.com

Yes port 2222
Yes that is a test user I use .

why are you using sudo?

Here is how I just now set up passwwordless into my server:

[tracy@daphne .ssh]$ ssh-keygen -t ed25519 -C "your_email@domain.com"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/tracy/.ssh/id_ed25519): 
Enter passphrase for "/home/tracy/.ssh/id_ed25519" (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/tracy/.ssh/id_ed25519
Your public key has been saved in /home/tracy/.ssh/id_ed25519.pub
The key fingerprint is:


+----[SHA256]-----+
[tracy@daphne .ssh]$ ls
id_ed25519  id_ed25519.pub  known_hosts  known_hosts.old
[tracy@daphne .ssh]$ ssh-copy-id super@annie
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/tracy/.ssh/id_ed25519.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
super@annie's password: 

Number of key(s) added: 1

Now try logging into the machine, with: "ssh 'super@annie'"
and check to make sure that only the key(s) you wanted were added.

[tracy@daphne .ssh]$ ssh super@annie
[super@annie ~]$ 

No sudo

When I tried it without sudo I got this:

[demo@Manjaro .ssh]$ ssh-copy-id -p 2222 demo@192.168.68.21
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ssh-add -L
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 2 key(s) remain to be installed -- if you are prompted now it is to install the new keys
demo@192.168.68.21's password:
sh: line 1: .ssh/authorized_keys: Permission denied

Well sudo will not help you. can you log in to the server

Yeah If I just ssh into it ,it works to get into it.

[demo@Manjaro .ssh]$ ssh -p 2222 demo@192.168.68.21
1 Like

log in and check your user’s .ssh directory, you can delete the authorised_keys file there, and do the same in your client and start again. You can safely clear the .ssh directory,especially if it has only the server data in there, the data can be regenerated.

1 Like

When I went to edit the authorized_keys file it told me it was unwriteable.
Turned out it was owned by root.
chown to the user and like magic it worked.
I don’t know how it was root but it was.
Thanks for helping again.
It is late I am going to bed.
Goodnight and thanks again.

1 Like

Probably because you used sudo ssh-copy-id -p 2222 demo@192.168.68.21

2 Likes

Many moons ago I posted this in Contributions > Tutorials, describing How To setup your own ssh service

1 Like

Thank you for this guide. I will be implementing the suggestions in this guide .

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.