How to access and modify a SSH file on mac?

53,036

Solution 1

Start Terminal and create the ~/.ssh directory if it doesn't exist:

mkdir -p ~/.ssh

Now go into the directory:

cd ~/.ssh

Now open the file config with the default editor:

open -t config

If it says that file doesn't exist, create it with:

touch config

and try opening again:

open -t config

When you edit the file, make sure it is "Plain Text" using the menu at the top of the screen and clicking Format->Make Plain Text.

Set the permissions as instructed in your tutorial.

Solution 2

To locate .ssh in High Sierra, and possibly even up to the latest macOS, do the following:

  1. Navigate to your boot disk in finder... usually Macintosh HD, disk1, or whatever it's named.

  2. From there, hold down Shift Cmd .. This will reveal hidden files, and the goal at this point is to simply do that. If this command doesn't work for you, find out if there are any new commands that do that for your macOS version. For me, on High Sierra, this command works perfectly.

  3. After that, grey files should appear. Click on the users folder, then click on your user, whatever you named it. Maybe you named it, Tom, Jake, or whatever, but your user should be in this users folder.

  4. After clicking it, scroll up until you see the folder named .ssh. It should also be greyed out because it's hidden.

  5. If you are not able to find it, then to make sure that you don't have it and you are just not a very good searcher, go to your terminal app and run the following command: cd .ssh. This command will immediately bring you into the folder if it exists, and if you want to add stuff to it manually, I advise against it for now.

  6. If you do the above command and it gives you some kind of error such as no such directory or something like that, it means you don't have that folder for real.

  7. There are other things you can do to find out for sure if you even have ssh capacity on your computer.

  8. Navigate back to your disk

  9. Along side the users folder, there should another folder named etc. This folder should be greyed out.

  10. Click it. Once you are there, you should have an ssh folder named ssh. Click it, and it should contain three folders: moduli, ssh_config, and sshd_config. If it has more, it's fine, but it must have these three folders.

  11. If you don't find these folders or even the ssh folder, then you probably don't have ssh capacity, or maybe these folders are located somewhere else. To make sure, I would do a search in Finder for these two folders, .ssh or ssh.

  12. I mentioned that you shouldn't try to edit any of these folders or files without knowing exactly what you are doing and what it will do because ssh will literally create new folders itself. When you generate a new connection, ssh will add that into another file named know_hosts under the .ssh folder. If you modify these names without knowing what they do, you could ruin your capacity to even create new connections, and such.

Anyway, research this issue further to be certain. And this is all I know about ssh on macOS High Sierra.

Share:
53,036
SwiftyJD
Author by

SwiftyJD

Updated on January 20, 2022

Comments

  • SwiftyJD
    SwiftyJD over 2 years

    I'm trying to setup SSH on my computer but not sure how to access the ~/.ssh/config file. From github's website they mention this file has to be modified but I'm not sure where its located or how to modify it.

    On Github:

    If you're using macOS Sierra 10.12.2 or later, you will need to modify your ~/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.

    Host *
     AddKeysToAgent yes
     UseKeychain yes
     IdentityFile ~/.ssh/id_rsa