SSH::Generating a Key Pair for MAC

SSH::Generating a Key Pair for MAC

Generating SSH keys on Mac OS X

The following outlines the process of setting up key-based SSH login on Mac OS X and Mac OS X Server. To set up key-based SSH, you must generate the keys the two computers will use to establish and validate the identity of each other. This doesn’t authorize all users of the computer to have SSH access. Keys must be generated for each user account.
Verification of .ssh folder
1. Verify that an .ssh folder exists in your home folder by entering the command: ls -ld ~/.ssh.
  If .ssh is listed in the output, move to step 2. If .ssh is not listed in the output, run mkdir ~/.ssh and continue to step 2.
Change directories
2. Change directories in the shell to the hidden .ssh directory by entering the following command: cd ~/.ssh
 
Key generation
3. Generate the public and private keys by entering the following command: ssh-keygen -b 1024 -t rsa -f id_rsa ”The -b flag sets the length of the keys to 1,024-bits, -t indicates to use the RSA hashing algorithm, -f sets the file name as id_rsa. Keys are equivilant to passwords so you should keep them private and protected.
  [root@e2e ~]# ssh-keygen -b 1024 -t rsa -f id_rsa Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): press Enter to set the passprase to null
Two files will be generated after this step. i.e, id_rsa.pub (public key) and id_rsa (Private Key).
  Once the keys are generated requested you to share the id_rsa.pub file, So that we can add the key to the server in authorized_keys file NOTE : DO NOT SHARE YOUR PRIVATE KEY (id_rsa) Prior to scp/ssh we have to add the identity to the user for whom we generated the key, by running
$ ssh-add ~/.ssh/id_rsa
 
    • Related Articles

    • Creating SSH Tunnel From Linux or MacOS

      To create a ssh tunnel, Please follow the below steps: Use the following command to create a ssh tunnel. $ ssh -L 3306:127.0.0.1:3306 username@server.com username@server's password: We are creating SSH tunnel from local port 3306 from our computer to ...
    • Set-up SSH keys

      Introduction: Setting up SSH based security to access your server is a much more effective way than the use of a manual root password. Cracking the security system of a VPS depending on SSH keys is nearly impossible since it secures your VPS in a ...
    • Disabling reverse dns lookups in ssh

      Sometimes it is very annoying to wait ten's of seconds to finish remote ssh server's reverse dns lookup procedure. Steps to disable 1. Open configuration file /etc/ssh/sshd_config. 2. Find UseDNS directive and set value to no. 3. In case this ...
    • How to setup SSH keys using PuTTy Tool- Windows Os?

      About SSH keys: Use of SSH keys favors a very boosted form of security against the brute forces attacking a virtual private server. Use of passwords, independent of their complex nature is always vulnerable towards security threats. SSH keys provides ...
    • Establish SSH server access via only a specific IP address

      Introduction The purpose of this article is to explain the procedure of manipulating Iptables in order to grant access to a particular server only through a specific IP address. To do this you need to append a rule into the Iptables chain. Follow the ...