Facebook Share
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Log in with an SSH private key on Linux and Mac
#1
Brick 
This example below demonstrates how to use a private key to log in to a Linux server by using a private key by using a Terminal session on OS X.

However, you can follow the same process to use a private key when using any terminal software on Linux.


To complete this process, you need the following software applications:
  • ssh - SSH client software is installed on your Linux or OS X operating system by default

  • text editor - This example uses the vim text editor.
Log in with a private key
  1. Using a text editor, create a file in which to store your private key. This example uses the file key.txt.

  2. To edit the file in vim, type the following command
  1. vim key.txt
  2. After the editor starts, press i to turn on insert mode.
  3. Paste the private key into the file. Be sure to include the BEGIN and END lines.
Code:
-----BEGIN RSA PRIVATE KEY-----
....
....
....
-----END RSA PRIVATE KEY-----


  1. To save your changes, press Esc.
  1. Type :wq to write the file and return to the command line.
  1. Run the following command to change the file permissions to 600 to secure the key. 
  1. You can also set them to 400. This step is required: 

Code:
chmod 600 key.txt

  1. Use the key to log in to the SSH client as shown in the following example, which loads the key in file key.txt, and logs in as user demo, to addess gigebox.com:

Code:
ssh -i key.txt demo@gigebox.com

  1. When the prompt to confirm the connection request is displayed, type yes and then press Enter.
  1. If your SSH key requires a password, enter it when prompted to complete the connection.
| GIGEBOX.COM
| High Performance Business Hosting.
| https://www.gigebox.com
Reply Return to top


Possibly Related Threads...
Thread Author Replies Views Last Post
  Linux vs Microsoft Sweerie_banana 3 328 05-09-2018, 05:41 AM
Last Post: Sweerie_banana

Forum Jump:


Users browsing this thread: 1 Guest(s)