Skip to content
Technology News Information & Jobs

Technology News Information & Jobs

Ubuntu Tutorials, Ubuntu How To , Linux Tips, Tech Jobs

  • Work with US
  • Search Jobs
  • Post a Job
  • Contact Us
  • Ubuntu
    • Ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Themes
  • Linux
  • Laptops
  • Tutorials
  • Job Dashboard
  • Toggle search form
How To Add SSH Public Key To Server

How To Add SSH Public Key To Server

Posted on April 5, 2022February 23, 2023 By admin

Methods to add ssh public key to the server

In this tutorial, we will show you the methods to copy the public ssh key to the server. The public-key authentication method requires you to copy your public SSH key to the server’s authorized_keys file. You might be wondering why we need to add the SSH key to the server as the reason to add ssh key to the server is to allow you to access a server via SSH without a password. Here are two methods to copy the public ssh key to the server.

How To Add SSH Public Key To Server

Let’s go through the process of adding the ssh key to the server.

Copy ssh public key to remote server using ssh-copy-id:

In this very first method, we will copy the ssh public key to the server using ssh-copy-id tool. In this process, we will copy the personal computer’s public key to the list of the authorized keys on the remote server. The authorized_keys file is in the ~/.ssh/

ssh-copy-id -i ~/.ssh/id_rsa.pub validusername@IP_ADDRESS_OF_THE_SERVER

When prompted, enter the password for your user account at the remote server. Your public key should be copied to the remote server.
~/.ssh/id_rsa.pub  is the default location for the public ssh key. If you want to use another public key rather than the one in the default location, use the -i option.

READ More Relevant Stuff:  Configure CTRL+ALT+DEL As Task Manager In Ubuntu 20.04/18.04

Manually copy the public ssh key to the server

In another method, we can manually copy the ssh key to the server.  This method is useful when your server doesn’t allow you ssh login via password. In this process, you need to ask the end-user to provide their pubic key at first.

cat ~/.ssh/id_rsa.pub

Manually append your public key to the remote ssh server’s key to the authorized_keys file. For example, copy the content of your ~/.ssh/id_rsa.pub to the server’s ~/.ssh/authorized_keys file.

Using the following command combination

cat ~/.ssh/id_rsa.pub | ssh user@remote-host 'cat >> ~/.ssh/authorized_keys'

Now, create new directories and files in the end user’s home directory so that you can add the public key of the end user that you have asked for in the previous step.


Now add the public key of the user in /home/user_name/.ssh/authorized_keys file

vim /home/username/.ssh/authorized_keys

Save and close the file.

Now, if your end-users tried to connect to a remote server then they might come across a permission denied error or something like this “r “sign_and_send_pubkey: signing failed: agent refused operation Permission denied (publickey)”.

One of the reasons for this is due to file permission on ssh file.  Make sure to set the correct file permissions:

chmod 700 /home/username/.ssh && chmod 600 /home/username/.ssh/authorized_keys

Change the ownership to the user:

chown -R username:username /home/username/.ssh

Now your end-user can log in to the server without any issue

How To Ubuntu Tags:ssh

Post navigation

Previous Post: Epic Programming Jokes Only Programmers Will Get
Next Post: Fix sudo apt-get install openssh-server not working error : Enable SSH Server on Ubuntu

Related Posts

How To Fix curl: (6) Could not resolve host Error in Linux How To Fix curl: (6) Could not resolve host Error in Linux How To Ubuntu
10+ Basic Cat Command Examples in Linux [2023] 10+ Basic Cat Command Examples in Linux [2023] How To Ubuntu
How To Install Docker On Ubuntu 22.04 LTS [User Guide] How To Install Docker On Ubuntu 22.04 LTS [User Guide] How To Ubuntu
How to Fix Unable To Locate a Package In Ubuntu 22.04 LTS How to Fix Unable To Locate a Package In Ubuntu 22.04 LTS How To Ubuntu
Run Linux On Windows 11: Install Linux Bash Shell on Windows 11 Run Linux On Windows 11: Install Linux Bash Shell on Windows 11 How To Ubuntu
How to Install WhatsApp Client On Ubuntu 22.04 LTS/ Ubuntu 20.04 LTS Install WhatsApp Client On Ubuntu 22.04 LTS/ Ubuntu 20.04 LTS How To Ubuntu

Recent Posts

  • New Job Search October 10, 2025
  • How To Enable Hibernate in Ubuntu 22.04 LTS May 20, 2024
  • Popular Ubuntu Games: Top 5 Games To Play March 17, 2024
  • WordPress | Your site doesn’t include support for the “generateblocks/container” block GenerateBlocks Plugin February 11, 2024
  • Ubuntu Autoremove Command Debian Autoremove Command February 10, 2024
  • How To Mount Windows 11 Shares on Debian Linux December 7, 2023
  • Anonymous Browsing 101: A Deep Dive Into Residential Proxies November 20, 2023
  • How To Correctly Install Uninstall Linux Ubuntu Nvidia Drivers Fast October 31, 2023
  • Ethical Web Design: The Dos and Don’ts October 28, 2023
  • Understanding the Role of Security Operations Center October 25, 2023
  • The Positive Effects of AI Tools and Online Services on Students Successful Essay-Writing Skills October 3, 2023

Categories

  • Android
  • Apple
  • Blogs
  • Debian
  • Fix
  • Gadgets
  • Game
  • Google
  • How To Ubuntu
  • Internet
  • Laptops
  • Linux
  • Linux Commands
  • Linux Game
  • Linux Mint
  • News
  • Operating Systems
  • Security
  • Technology
  • Themes
  • Tools
  • Tutorials
  • Ubuntu
  • ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Windows 11
  • Wordpress
  • Search Jobs
  • Post a Job
  • Job Dashboard
  • Contact Us
  • About US
  • Cookie Policy
  • Terms and Conditions
  • Privacy Policy
  • Sitemap
  • Write For US

Tags

android apps centos ChatGPT command Commands Debian deepin Desktop docker Fedora fix game games Gaming gnome google kernel linux linux commands linux kernel Linux laptops Linux Mint Linux themes minecraft NVIDIA Python Raspberry Pi sysadmin themes ubuntu ubuntu 18.04 Ubuntu 18.04 LTS Ubuntu 20.04 ubuntu 20.04 lts Ubuntu 22.04 LTS Ubuntu games Ubuntu kernel ubuntu themes ubuntu tutorial VirtualBox Windows Windows 11 Wine WSL
itsubuntu.com is an Equal Opportunity Employer. For Advertisement, Jobs, Guest posts, and any other thoughts, email us at [email protected]
  • Cyber/Data/Privacy Litigation Attorney (Associate)

    • Chicago, IL
    • Direct Counsel
    • Full Time
  • Data Entry / Report Writer (Mon-Fri, Day Shift)

    • Salt Lake City, UT
    • Nelson Laboratories Holdings, LLC
    • Full Time
  • Grocery Order Writer (Buyer / Inventory Replenishment) – Full Time

    • Honolulu, HI
    • Whole Foods Market
    • Full Time
  • TECHNICAL EDITOR AND WRITER 3 with Security Clearance

    • Newport News, VA
    • Innova Solutions, Inc.
    • Full Time
  • Software Developer 1 (1 Year Fixed Term)

    • Stanford, CA
    • Stanford University
    • Full Time
  • Engineer Graduate: (Machine Learning Engineer, Data-Search-TikTok.US – San Jose) – 2026 Start (PhD) (San Jose)

    • San Jose, CA (Remote)
    • TikTok
    • Full Time
  • Experienced Service Writer

    • Claremont, CA
    • Mazda of Claremont
    • Full Time
  • Process Engineer – Electrical

    • Deridder, LA
    • Packaging Corporation of America
    • Full Time

Copyright © 2025 Technology News Information & Jobs.

Powered by PressBook Grid Blogs theme