Questions about SSH
When I log into a server (that I own) for the first time using SSH, Terminal says the server can not be verified and it displays a fingerprint.
Where does the "fingerprint" that is displayed in Terminal come from? From my laptop or from the server? |
That is from the server.
|
if I understood it well: fingerprint comes from the server and stored on the client. That way ssh can inform you if you ssh to the same server name but that was replaced in the meantime.
see ~/.ssh/known_hosts |
Hi again,
As mentioned in your other question, this is the MD5 hash of the server's public key. The server keys are usually in /etc/ssh/ssh_host_{dsa,rsa}. You can obtain the fingerprint by running: Code:
ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub |
The reason for this is to protect against man-in-the-middle attacks. The first time you connect to a server it stores its key. If an imposter machine comes in, takes over the IP of the remote server (or hijacks the DNS to point the domain to a new location), and starts up a fake SSH server process in order to steal your username and password, as soon as you try to connect to it you'll be notified that this is not the same server you connected to before.
|
Quote:
If the fingerprint is created by using the public key on my server, which public key are we talking about? Is this the public key that was generated on my laptop and then uploaded onto my server? Or is this possibly a public key that was generated on the server by my web host? Follow me? |
Quote:
I have another VPS with the same host. This is how I recall things working when I set that one up... - I ran this on my laptop: ssh-keygen -t rsa -b 2048 - I uploaded the public key from the above command to my VPS - I authorized the public key. - I went into Terminal and typed: ssh cpaneluser@myserveripaddress -p 22 - I got a message saying it couldn't verify the authenticity of the server at myserveripaddress - There was also a fingerprint displayed - presumably from my server - The problem is that when I went to compare this fingerprint displayed in Terminal during initial ssh login against the fingerprint my web host cliamed was my server, they did not match!! The web host could not explain why, and I was ultimately told, "You just have to blindly say 'yes' to that first message, so your laptop can connect to the VPS and then the VPS will send your public key (?) back to it and store it in the "known_hosts" file. I think my web host was wrong, and I should have been able to have matching fingerprints the first time I tried to log in!! What do you say about this? |
Quote:
|
Quote:
Quote:
FYI - when you connect to a server for the first time and accept the key, it gets placed in ~/.ssh/known_hosts on your local machine. You can open up that file and find the key for your server, and compare that to what you were told it should be by the web host (assuming that's the key the web host gave you). |
Quote:
8d:32:0E:9A:...... My web host was insistent that the fingerprint on my VPS was ___A____, but then why didn't I see that in terminal? Why would the fingerprint I saw in Terminal NOT match the fingerprint my web host emailed me not match, when I am 99.9% sure that I did connect to my VPS when I had to break down and blindly type "yes" and hit <enter> even though the fingerprints did not match? |
Quote:
Then what other fingerprint would level-2 tech support be finding for me and emailing me? The idea is that you call your web host n advance, they get YOUR vps's fingerprint, then you log in for the first time using SSH in Terminal, it fetches that SAME fingerprint from your vps, you verify that they match, and you type "yes" to sign on. THEN, the server passes the ____i forget which one____ back to your computer and writes it into the "known_hosts" file, so in the uture when you log in, you don't have to get that same prompt asking if the fingerprint is legitimate, right? This all boils down to either something is broken and that is why the fingerprints don't match, OR my web host is an idiot and can't get the the CORRECT fingerprint to compare to what SSH is showing me in Terminal. That is how I see this annoying issue... Thoughts? |
Maybe he gave you the rsa key, and due to your ssh settings you authenticated over dsa?
It doesn't have to be complicated, if you're concerned, just LOOK. On your local machine, open up ~/.ssh/known_hosts, find the system you're referring to here. The beginning will look something like: Code:
name-of-host ssh-rsa slihdlijaflafjlsdfljasf... Now log into your server, go to /etc/ssh, and open the applicable public key file, either ssh_host_dsa_key.pub or ssh_host_rsa_key.pub, or ssh_host_ed25519_key.pub, or whatever. It should match what's in your known hosts file. Now look at what the provider told you, maybe they gave you one of the other ones. |
Quote:
Quote:
111.222.3333.44 ssh-rsa AAAAB2MzbS7yp2E... Quote:
This past weekend, the web host supposedly ran this... # ssh-keygen -lf .ssh/id_rsa.pub As far as I know, that is creating a public/private key pair on the server. What in the hell does that have to do with the public key I created on my laptop and then installed on my VPS?????? Apparently that command generated this... 2048 06:ef:47:d7:d5:14... .ssh/id_rsa.pub (RSA) This is where I believe the problem is... I created a public/private key pair on my LAPTOP and then I installed the PUBLIC KEY onto my VPS. So when I asked the web host for my fingerprint, I wanted the fingerprint created from the public key THAT I CREATED ON MY LAPTOP. Based on the command they supposedly ran above, I'd say they overwrote MY public key with a new one. Follow me? (I think all of this being difficult falls onto my web host...) |
Quote:
Code:
ssh-keyscan localhost > /tmp/x && ssh-keygen -lf /tmp/x && rm /tmp/x Quote:
The command above created a key pair for your user on the server. This is not the same thing as the server's host key. This key would only be of any use if you want to connect from the server to somewhere else, and plays no role at all in the connection from your laptop to the server. Quote:
You would not need their help to get the fingerprint for the key you generated anyway; simply run "ssh-keygen -lf ~/.ssh/id-rsa.pub" on your laptop for that. Quote:
Getting back to your real concern, I'd suggest you ask your hosting provider to send you a copy of the /etc/ssh/ssh_host_rsa_key.pub file. This should match the entry in your ~/.ssh/known_hosts file for that server. |
Quote:
|
All times are GMT -5. The time now is 01:51 AM. |