O
O
Oleg2018-05-24 22:15:03
SSH
Oleg, 2018-05-24 22:15:03

I can't connect via ssh from the second PC. Cause?

Set up ssh key authorization on the remote server. Everything worked out great at work. Came home, repeated, but the remote server does not start up with the error "Permission denied (publickey)". Checked - my second client key was added on the server to .ssh/authorized_keys. At the same time, the computer at work continues to connect successfully.
I generated the keys with the command:

ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_remote_$(date +%Y-%m-%d) -C "Key for Remote"

(True, at work, before generating, I also created a client config from the instruction .)
I copied it to the server in the same way:
ssh-copy-id -i .ssh/id_ed25519_remote_2018-05-24.pub <remote_server>

Although the public key files were obtained on both clients with the same names (maybe this is the reason), there are 2 lines in ~/.ssh/authorized_keys on the server, and the second line definitely refers to the home computer.
There is also a feature that both work and home computers have the same external IP (due to the use of OpenVPN). But on a working computer, you can open more than one ssh session to this server.
In the logs on the server, a line is added to an attempt to connect from a home PC:
May 24 22:09:55 <remote_server> sshd[4707]: Connection closed by authenticating user oleg MY_EXTERNAL_IP port 49406 [preauth]

Ready to provide any additional information.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg, 2018-05-28
@Batiskaf_stv

Apparently it was the config instructions .

~/.ssh/config
# Ensure KnownHosts are unreadable if leaked - it is otherwise easier to know which hosts your keys have access to.
HashKnownHosts yes
# Host keys the client accepts - order here is honored by OpenSSH
HostKeyAlgorithms [email protected],[email protected],ssh-ed25519,ssh-rsa,[email protected],[email protected],[email protected],ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256

KexAlgorithms [email protected],ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256
MACs [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,[email protected]
Ciphers [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr

After creating this config at home, I was unable to SSH into the servers at home, which I used to access with keys for a long time. Cleaned up known_hosts
after some tinkering ; registered the host key from the instruction in the config file of the correspondence records (the case of host names is important!); re-copied
ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]

keys to all servers - and EARNED.

A
Anatoly Kirsanov, 2018-05-25
@bitrixworkshop

It is very likely that from the external network (from home) you are connecting to the wrong node that you think.
When everything is configured correctly, it just works, nothing else needs to be done on the client (of course, except for the presence of a private key).
I have personal experience of working both locally (home network, server and client on different PCs) and remotely (client on 3G Internet, and server on a router with forwarded port 22).
Are you port forwarded? Whatever, the main thing is that you know its number and ssh definitely responds to it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question