SSH key associated with root directory

9

3

In OSX (Linux), how do I get to the SSH keys with my root directory?

Spencer

Posted 2011-02-20T03:08:06.050

Reputation: 213

2Do SSH keys have something to do with directories? – Matti Virkkunen – 2011-02-20T03:09:46.660

"OSX (Linux)" ... ok... now can you say something to make me think that you aren't a bot and should be trusted with ssh keys? Also, what Matti said. – TomMD – 2011-02-20T03:14:44.717

3"I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." -- Charles Babbage – Simon – 2011-02-20T03:25:00.217

Answers

3

Not entirely sure what you are asking....

But for Linux ssh files (public rsa, authorized keys, etc) are stored in ~/.ssh

So for root they would be /root/.ssh/

Not sure if this is the same for OSX though.

threenplusone

Posted 2011-02-20T03:08:06.050

Reputation: 146

How can I get there? If i do sudo cd /root/.ssh/ it says sudo: cd: command not found – clankill3r – 2017-03-08T14:23:19.737

@clankill3r That error indicates you don't have the "cd" command... maybe try 'cat'ing the file directly? – threenplusone – 2017-03-09T05:47:17.803

1The reason is that cd isn't a program, but a single UNIX command. sudo runs programs as superuser. What you'd want to do is switch your shell session to superuser (type su), and then do what you'd like. When you're done with being a superuser, type exit to return to normal. – Sam Bobel – 2018-04-25T19:44:10.570

14

In OSX, SSH keys are stored in ~/.ssh/id_dsa and ~/.ssh/id_rsa, where ~ is the home folder of the user. Normal users' home folders are generally stored in /Users/, but root's home folder (on OSX; not on Linux) is /var/root. To get to these from your root directory (i.e. /) simply use the cd command as you normally would, although bear in mind that only root is likely to have access to /var/root. Alternatively, you can access hidden folders (those whose names begin with a '.' from the Finder by selecting "Go to Folder..." from the "Go" menu and typing the desired path into the input box that comes up.

Bear in mind that you will need to activate the root user before you can log in using it on the client version of OSX. Be certain you know what you're doing and understand the risks before you enable the root user, especially if you're going to do so on a computer that arbitrary machines will be able to SSH into.

Scott

Posted 2011-02-20T03:08:06.050

Reputation: 5 323

1

In OSX all ssh keys are generally stored under the user/.ssh directory Of course - you can move them anywhere if needed (may be needed for access to EC2 due to permissions)

Chances are since you are asking - YOU MAY NOT HAVE AN SSH KEY GENERATED YET...

So -let's start there first:

From the terminal window simply run: ssh-keygen -d and you can then follow the prompts -

Once complete if you were to browse to your terminal and then once it is opened simply type

cd .ssh

you should be able to view your ssh keys

If you wish to copy the SSH key to another linux/nix based system simply use scp

scp ~/.ssh/id_dsa.pub (or whatever name you gave it) www.servernameorIPaddress.com:/root/.ssh/authorized_keys2

I would suggest always using the -d option when doing the keyGen simply because RSA keys are generally not used in Version 2 of SSH.

I hope that helps - if not feel free to ask for clarification and I will help you along.

---- one last note ----

If you are looking to use ROOT on your system - this link may help you a little bit: http://snowleopardtips.net/tips/enable-root-account-in-snow-leopard.html

Glenn Kelley

Posted 2011-02-20T03:08:06.050

Reputation: 136

0

  1. There is no OSX(Linux) maybe you mean OSX(Unix).

  2. There is no .ssh folder under root on OSX. You have to create it under /var/root.

    mkdir /var/root/.ssh
    

You can place your private key there. In case you get a warning about "UNPROTECTED PRIVATE KEY FILE!", you need to change permissions to your key.

chmod 600 id_rsa

Will look like this.

bob:.ssh root# ls -lah 
total 16
drwxr-xr-x  4 root  wheel   128B Apr  5 14:57 .
drwxr-x---  9 root  wheel   288B Apr  5 14:54 ..
-rw-------  1 root  wheel   1.7K Apr  5 14:54 id_rsa
-rw-r--r--  1 root  wheel   197B Apr  5 14:57 known_hosts

DimiDak

Posted 2011-02-20T03:08:06.050

Reputation: 111