LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Questions about SSH (https://www.linuxquestions.org/questions/linux-newbie-8/questions-about-ssh-4175573213/)

RobInRockCity 02-25-2016 10:48 AM

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?

lazydog 02-25-2016 10:54 AM

That is from the server.

pan64 02-25-2016 10:54 AM

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

cliffordw 02-25-2016 11:01 AM

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
# and
ssh-keygen -lf /etc/ssh/ssh_host_dsa_key.pub

Which of these keys get used, and thus which fingerprint you get presented with, is determined by a negotiation between the client and server, depending on a number of configuration settings on both ends.

suicidaleggroll 02-25-2016 11:19 AM

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.

RobInRockCity 02-25-2016 12:42 PM

Quote:

Originally Posted by cliffordw (Post 5506028)
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
# and
ssh-keygen -lf /etc/ssh/ssh_host_dsa_key.pub

Which of these keys get used, and thus which fingerprint you get presented with, is determined by a negotiation between the client and server, depending on a number of configuration settings on both ends.

I responded to you in my other thread and my question - repeated here - was this...

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?

RobInRockCity 02-25-2016 12:49 PM

Quote:

Originally Posted by suicidaleggroll (Post 5506036)
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.

Not to jump too far ahead, but...

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?

suicidaleggroll 02-25-2016 12:52 PM

Quote:

Originally Posted by RobInRockCity (Post 5506066)
I responded to you in my other thread and my question - repeated here - was this...

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?

Your laptop has nothing to do with it. You can connect to that server from 10 different client machines, and all 10 client machines will be shown and forced to accept the same key. The key you're talking about here is generated when sshd is first installed on the server I believe.

suicidaleggroll 02-25-2016 12:55 PM

Quote:

Originally Posted by RobInRockCity (Post 5506071)
Not to jump too far ahead, but...

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.

All of that is irrelevant to the topic at hand

Quote:

Originally Posted by RobInRockCity (Post 5506071)
- 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!!

We need more information to answer that. What did the keys look like? Was the syntax similar? We have no idea what kind of fingerprint your web host gave you.

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).

RobInRockCity 02-25-2016 04:08 PM

Quote:

Originally Posted by suicidaleggroll (Post 5506073)
All of that is irrelevant to the topic at hand

We need more information to answer that. What did the keys look like? Was the syntax similar? We have no idea what kind of fingerprint your web host gave you.

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).

The fingerprint in Terminal and the fingerprint they emailed me looked like this:
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?

RobInRockCity 02-25-2016 04:13 PM

Quote:

Originally Posted by suicidaleggroll (Post 5506072)
Your laptop has nothing to do with it. You can connect to that server from 10 different client machines, and all 10 client machines will be shown and forced to accept the same key. The key you're talking about here is generated when sshd is first installed on the server I believe.

So the fingerprint that SSH sends back to me in Terminal on my laptop was coming from my VPS, right?

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?

suicidaleggroll 02-25-2016 04:54 PM

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...
Pay attention to that ssh-rsa part, if it says ssh-rsa, then it's rsa, if it says ssh-dsa, then it's dsa. It might not be either of those, it could be ecdsa, or ed25519, or whatever, just identify it.

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.

RobInRockCity 02-25-2016 05:26 PM

Quote:

Originally Posted by suicidaleggroll (Post 5506193)
Maybe he gave you the rsa key, and due to your ssh settings you authenticated over dsa?

No.


Quote:

Originally Posted by suicidaleggroll (Post 5506193)
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...
Pay attention to that ssh-rsa part, if it says ssh-rsa, then it's rsa, if it says ssh-dsa, then it's dsa. It might not be either of those, it could be ecdsa, or ed25519, or whatever, just identify it.

In the known_hosts file I see...
111.222.3333.44 ssh-rsa AAAAB2MzbS7yp2E...


Quote:

Originally Posted by suicidaleggroll (Post 5506193)
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.

I don't have root access, so I don't believe I can do this step.


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...)

cliffordw 02-26-2016 01:41 AM

Quote:

Originally Posted by RobInRockCity (Post 5506204)
I don't have root access, so I don't believe I can do this step.

You can see the server's key as a non-root user by running
Code:

ssh-keyscan localhost > /tmp/x && ssh-keygen -lf /tmp/x && rm /tmp/x
Quote:

Originally Posted by RobInRockCity (Post 5506204)
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)

There is a server key, used by sshd to identify the server. Separate from that individual users can have user keys, which allows them to authenticate without passwords.
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:

Originally Posted by RobInRockCity (Post 5506204)
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.

This is where the confusion lies, yes. You're still off the mark, though ;-) The fingerprint you get asked to confirm is the HOST key, not the USER key.

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:

Originally Posted by RobInRockCity (Post 5506204)
Based on the command they supposedly ran above, I'd say they overwrote MY public key with a new one.

Nope, different files (unless the wrong files were copied). The ~/.ssh/id-rsa.pub file on the server is for use by the account on the server to connect elsewhere. For your laptop to connect to the server, a copy of your public key should be added to ~/.ssh/authorized_keys.

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.

lazydog 02-26-2016 10:06 AM

Quote:

Originally Posted by cliffordw (Post 5506375)
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.

@OP: From what I have read the disconnect is between the keyboard and the seat. Not understanding how key-pairs work properly and what key you should be seeing. I would suggest you contact your hosting and work out your confusion with them. They can tell you exactly what you should be seeing.

RobInRockCity 02-26-2016 11:57 AM

Quote:

Originally Posted by lazydog (Post 5506575)
@OP: From what I have read the disconnect is between the keyboard and the seat. Not understanding how key-pairs work properly and what key you should be seeing. I would suggest you contact your hosting and work out your confusion with them. They can tell you exactly what you should be seeing.

If I thought my web host was able to competently help, I wouldn't be here...

RobInRockCity 02-26-2016 12:02 PM

Quote:

Originally Posted by cliffordw (Post 5506375)
You can see the server's key as a non-root user by running
Code:

ssh-keyscan localhost > /tmp/x && ssh-keygen -lf /tmp/x && rm /tmp/x

Can you explain what that code does and where I would run it? (Sorry, I'm not a system admin)


Quote:

Originally Posted by cliffordw (Post 5506375)
There is a server key, used by sshd to identify the server. Separate from that individual users can have user keys, which allows them to authenticate
without passwords.
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.

So my web host gave me the wrong info...


Quote:

Originally Posted by cliffordw (Post 5506375)
This is where the confusion lies, yes. You're still off the mark, though ;-) The fingerprint you get asked to confirm is the HOST key, not the USER key.

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.

What do I need to do to get a fingerprint that I can compare against the fingerprint I see when I first try to SSH in to my server?


Quote:

Originally Posted by cliffordw (Post 5506375)
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.

Is it safe to do that via email?

Would I be giving away details of my server or keys that I shouldn't?

suicidaleggroll 02-26-2016 12:48 PM

Quote:

Originally Posted by RobInRockCity (Post 5506633)
What do I need to do to get a fingerprint that I can compare against the fingerprint I see when I first try to SSH in to my server?

That would the command cliffordw just gave you:
Code:

ssh-keyscan localhost > /tmp/x && ssh-keygen -lf /tmp/x && rm /tmp/x
Run it on the VPS, it will print out the fingerprint that you were shown, and accepted, when you first tried to ssh into the system.

If you want to know what it does, there are three parts:
1) ssh-keyscan localhost > /tmp/x
This dumps out the server key for the system on which you run the command into a file called "x" located in /tmp/. This would be the same as running "cp /etc/ssh/ssh_host_rsa_key.pub /tmp/x", which is the file I asked you to look at earlier and you just assumed you wouldn't be able to and didn't try...the public key files are world-readable, you don't need to be root.

2) ssh-keygen -lf /tmp/x
The -f flag tells it to read from the provided file, the -l flag tells it to print the fingerprint

3) rm /tmp/x
Cleans up the temporary file that you created with #1.

All of which could be shortened to simply:
Code:

ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub

RobInRockCity 02-26-2016 02:32 PM

suicidaleggroll,

I was trying to follow your instructions, but I have the following issue in Terminal when I try to ssh into my VPS. Here is what is happening...

Code:

user1s-MacBook-Pro:~ user1$ ssh vps-user@111.222.333.44 -p 22

The authenticity of host '111.222.333.44' can't be established.
RSA key fingerprint is 3c:91:bb:81:ef:23:f1:b2:87:a5:2a:10:e8.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '111.222.333.44' (RSA) to the list of known hosts.

vps-user@111.222.333.44's password:


Why is it asking for a password?? The whole point of setting up a public/private key pair was so I just have to type in my passphrase on the private key, and NOT enter my cpanel password.

This is all very frustrating...

suicidaleggroll 02-26-2016 02:48 PM

Permissions are the usual cause.

On the remote server, run the following:
Code:

chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 750 ~

I'm assuming you already put your laptop's public key into ~/.ssh/authorized_keys on the server.

RobInRockCity 02-26-2016 05:52 PM

Quote:

Originally Posted by suicidaleggroll (Post 5506747)
Permissions are the usual cause.

On the remote server, run the following:
Code:

chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 750 ~


Dumb question, but how do I do that??

I have a VPS with CentOS6 and cPanel, but no Root access of my own. I thought the way I would execute your code above for the server key was supposed to be done after I SSH'ed into my VPS, but then I got that password issue.

So where and how do I run the chmod commands you recommend?


Quote:

Originally Posted by suicidaleggroll (Post 5506747)
I'm assuming you already put your laptop's public key into ~/.ssh/authorized_keys on the server.

No. I generated the key pair on my MacBook, and then I imported the public key into cPanel > Security > SSH Access > Manage Keys

So I can see my public key in cPanel, but I didn't do anything with ~/.ssh/authorized_keys

You'll have to help explain this to me as I learn all about Sys Admin stuff!

suicidaleggroll 02-26-2016 07:05 PM

I know nothing about cPanel, can't help you there.

You said you were prompted for a password, did you enter it? Do you know it?

RobInRockCity 02-26-2016 07:14 PM

Quote:

Originally Posted by suicidaleggroll (Post 5506867)
I know nothing about cPanel, can't help you there.

You said you were prompted for a password, did you enter it? Do you know it?

Yes, I know my cPanel password, but I didn't enter anything for fear my SSH connection is broken and a hacker might see it - or maybe I have already been hacked. :(

suicidaleggroll 02-26-2016 07:38 PM

The chances of that are incredibly low. Are you connecting using the domain name or IP address? If the IP, then the chances are practically non-existent.

RobInRockCity 02-26-2016 08:18 PM

Quote:

Originally Posted by suicidaleggroll (Post 5506882)
The chances of that are incredibly low. Are you connecting using the domain name or IP address? If the IP, then the chances are practically non-existent.

Think I am making some progress...

I took a chance and entered my password into SSH since my key pair stopped working.

At the command prompt on my server, I did this...

vps-user@111.222.333.44 [~}# ls

I see...

etc/
.ssh/

In etc/ is a directory called mydomain.com but there is nothing in it.

In .ssh/ I see...
authorized_keys
authorized_keys2
id_rsa.pub


I think this is one problem. Why do I have 2 authorized_key files?

I built a spreadsheet with two input fields (i.e. "Fingerprint from Web-Host" and "Fingerprint from Terminal") and created a formula to show MATCH/NO MATCH.

From there I went into TextWrangler and pasted the KEY from my MacBook's ~/.ssh/known_hosts file into "Fingerprint from Terminal".

Then I proceeded to run...

cat authorized_keys
cat authorized_keys2
cat id_rsa.pub

...and pasted the contents of each into the "Fingerprint from Web-Host" field. (In this case I am comparing KEYS and not fingerprints.)

There was NO MATCH in any of the three comparisons?!

So what is going on here???

suicidaleggroll 02-27-2016 07:56 AM

The fingerprint is not the public key. The fingerprint is calculated from the public key, and you've been given the command to do this calculation THREE TIMES already.

And as has already been explained to you, nothing you will find in ~/.ssh on the server has anything to do with this question, at all. The key you are looking for, the one that has to do with the server proving it is who it says it is, is in /etc/ssh.

pan64 02-27-2016 08:05 AM

authorized_keys2 is not used by default by any tool, it can only be a backup or something like that.

RobInRockCity 02-27-2016 10:56 AM

Quote:

Originally Posted by suicidaleggroll (Post 5507093)
The fingerprint is not the public key. The fingerprint is calculated from the public key,

When have I ever said that the keys were the fingerprint??


Quote:

Originally Posted by suicidaleggroll (Post 5507093)
and you've been given the command to do this calculation THREE TIMES already.

And I ran it.


Quote:

Originally Posted by suicidaleggroll (Post 5507093)
And as has already been explained to you, nothing you will find in ~/.ssh on the server has anything to do with this question, at all. The key you are looking for, the one that has to do with the server proving it is who it says it is, is in /etc/ssh.

Nothing personal, but the conversation would work better if people answered questions before moving on.

The conversation as evolved as I learn more, and I am taking people's advice and asking questions along the way to learn more.

RobInRockCity 02-27-2016 11:01 AM

Quote:

Originally Posted by cliffordw (Post 5506028)
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
# and
ssh-keygen -lf /etc/ssh/ssh_host_dsa_key.pub

Which of these keys get used, and thus which fingerprint you get presented with, is determined by a negotiation between the client and server, depending on a number of configuration settings on both ends.

I ran this code - after spent Friday night trying to figure out how to do command line - and it worked.

What I don't understand is why I can't see this path in Terminal?

(I explained this in another post, but it seems like my questions and comments get skipped a lot.)

How can I run that command when there is no visiable directory structure or file there?

suicidaleggroll 02-27-2016 11:31 AM

Quote:

Originally Posted by RobInRockCity (Post 5507174)
When have I ever said that the keys were the fingerprint??

Sorry, I misread your post. I thought you were comparing the keys in authorized_keys, known_hosts, etc. to the fingerprint the web host sent you. I see now that is not the case.

Quote:

Originally Posted by RobInRockCity
What I don't understand is why I can't see this path in Terminal?

(I explained this in another post, but it seems like my questions and comments get skipped a lot.)

How can I run that command when there is no visiable directory structure or file there?

I just re-read the thread and I do not see where you asked this earlier. If I missed it I apologize, but I'm not seeing it anywhere.
That said, I don't understand the question. What can't you see in the terminal? There's no directory structure or file where? Best guess at interpreting your question is that you're confused about the difference between relative and absolute paths:
http://www.linuxnix.com/abslute-path...-in-linuxunix/

RobInRockCity 02-27-2016 12:05 PM

Quote:

Originally Posted by suicidaleggroll (Post 5507187)
That said, I don't understand the question. What can't you see in the terminal? There's no directory structure or file where? Best guess at interpreting your question is that you're confused about the difference between relative and absolute paths:
http://www.linuxnix.com/abslute-path...-in-linuxunix/

cliffordw and you recommended this command to get the fingerprint from my server...
Code:

ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub

If I ssh into my server I end up here...
Code:

vps-user@mydomain.com [~] #
If I type ls at that prompt I see lots of directories including etc/

If I then type...
Code:

cd etc/

ls

then I see this...
Code:

./  ../  cacheid  mydomain.com/
There is no path: /etc/ssh/ssh_host_rsa_key.pub


And even if I look in the directory: mydomain.com/ I don't see anything in it.


So I concur - and thank you guys - for the command to get the fingerprint for my server, but am curious why that command works when I don't see that directory structure or file in my VPS account.

See?

pan64 02-27-2016 12:10 PM

not etc but /etc (probably)

suicidaleggroll 02-27-2016 12:29 PM

I repeat:
Best guess at interpreting your question is that you're confused about the difference between relative and absolute paths:
http://www.linuxnix.com/abslute-path...-in-linuxunix/

"etc" is a relative path that depends on your current location. "/etc" is an absolute path that does not depend on your current location. Unless you are currently sitting in "/", they are not the same directory. Please read the link.

RobInRockCity 02-27-2016 01:58 PM

Quote:

Originally Posted by suicidaleggroll (Post 5507206)
I repeat:
Best guess at interpreting your question is that you're confused about the difference between relative and absolute paths:
http://www.linuxnix.com/abslute-path...-in-linuxunix/

I read that. Would be nice if you'd read what I said and help me figure out where I am stuck.

Quote:

Originally Posted by suicidaleggroll (Post 5507206)
"etc" is a relative path that depends on your current location. "/etc" is an absolute path that does not depend on your current location. Unless you are currently sitting in "/", they are not the same directory. Please read the link.

Why do you seemingly read and response to every other thing I say? Come on, man.

I said above...
Quote:

There is no path: /etc/ssh/ssh_host_rsa_key.pub
Looks like an absolute path to me...

Would be nice if people answer my questions instead of talking around them...

suicidaleggroll 02-27-2016 02:41 PM

If the command ran without error, like you said it did, then the file does exist.

Run the following to see it:
Code:

ls -l /etc/ssh/ssh_host_rsa_key.pub
If you can't find it while navigating the directory structure, the only explanation is you don't understand relative vs absolute paths. Your example above shows you going to the "etc" subdirectory of your user's home directory, something like /home/vps-user/etc/, which is of course not the same place as /etc. You can always use the command "pwd" to see where you currently are.

RobInRockCity 02-27-2016 04:27 PM

Quote:

Originally Posted by suicidaleggroll (Post 5507241)
If the command ran without error, like you said it did, then the file does exist.

Run the following to see it:
Code:

ls -l /etc/ssh/ssh_host_rsa_key.pub
If you can't find it while navigating the directory structure, the only explanation is you don't understand relative vs absolute paths. Your example above shows you going to the "etc" subdirectory of your user's home directory, something like /home/vps-user/etc/, which is of course not the same place as /etc. You can always use the command "pwd" to see where you currently are.

I don't have access to /home/ because I am not root... :rolleyes:

suicidaleggroll 02-27-2016 05:06 PM

Quote:

Originally Posted by RobInRockCity (Post 5507272)
I don't have access to /home/ because I am not root... :rolleyes:

What? Did you run something and get an error, or are you just making assumptions again about what you can/cannot do without actually trying anything? Everyone can access /home, that's where everyone's home directory is (except root, which is at /root).

1) Log into the system
2) Run "pwd"

RobInRockCity 02-27-2016 06:44 PM

Quote:

Originally Posted by suicidaleggroll (Post 5507282)
What? Did you run something and get an error, or are you just making assumptions again about what you can/cannot do without actually trying anything? Everyone can access /home, that's where everyone's home directory is (except root, which is at /root).

1) Log into the system
2) Run "pwd"

When I ssh into the server I see this...
Code:

vps-user@mydomain.com [~]#
Then if I do this...
Code:

cd ../
I get this...
Code:

vps-user@mydomain.com [/home]#
Then if I do this...
Code:

vps-user@mydomain.com [/home]# ls
I get this...
Code:

/bin/ls: cannot open directory .: Permission denied

Which means that I am unable to navigate here to see that this exists...
Code:

ls -l /etc/ssh/ssh_host_rsa_key.pub

Yes I can run this, and yes it gives me the fingerprint, but that isn't what I asked...

I asked why I can execute something I can't navigate to.

suicidaleggroll 02-27-2016 09:33 PM

You don't have read permission for /home, but you still have execute permission which allows you to traverse the directory structure. The permissions on /home say nothing about the permissions on /etc or /etc/ssh anyway. You can't do an ls in /home, but you can still cd up to /, perhaps ls there, cd to /etc, ls there, etc.

RobInRockCity 02-28-2016 09:05 AM

Quote:

Originally Posted by suicidaleggroll (Post 5507356)
You don't have read permission for /home, but you still have execute permission which allows you to traverse the directory structure. The permissions on /home say nothing about the permissions on /etc or /etc/ssh anyway. You can't do an ls in /home, but you can still cd up to /, perhaps ls there, cd to /etc, ls there, etc.

Hah! That worked - I was able to "hack" my way into the /etc directory. :)


All times are GMT -5. The time now is 02:43 AM.