How to copy your SSH key to a new Digital Ocean Droplet

Add your SSH key to your server and remove root login

ssh
root login
digital ocean
ssh key
server

Published 4 years ago

If like me you created a Digital Ocean Droplet without adding the key in their control panel, here's how to do it when you've already created a droplet:

In a new terminal:

ssh-copy-id username@serverIp

You should then get:

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/c/Users/YourUser/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys username@serverIp's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'username@serverIp'" and check to make sure that only the key(s) you wanted were added.

Then disable being able to login with your root account with a password.

Edit:

/etc/ssh/sshd_config

Find: PermitRootLogin yes

Change: PermitRootLogin without-password

Other ways

Add your ssh key by making a ssh directory.

mkdir ~/.ssh

Then paste in your public key to authorized_keys and save

vim ~/.ssh/authorized_keys

Let's chat about your next project

Whether you're looking for a single contractor or a full team, I regularly collaborate with a trusted collective of designers and developers to deliver large-scale projects.

See also...

CnCNet - Website & App Development

Comprehensive design and development of responsive web and desktop apps for CnCNet, enhancing user experience and accessibility.

AR Configurator for E-Bikes

Bespoke augmented reality web configurator for E-Bikes, offering full customization options, including color choices and feature configurations.

Stock Investment App

Real-time stock investment app for web and mobile, built with TypeScript, React, and WebSockets, delivering fast, responsive, and data-driven experiences.

KickTown Football - Website

Custom-built website and API's for KickTown Football, integrating a merchandise store, booking system, and seamless user experience.

Tempest Rising - Official Website

Website development for Slipgate Ironworks' Tempest Rising, crafted to deliver a sleek, immersive experience for fans and players.

Facial Cosmetic Simulation - Web App

React and TypeScript-powered web app for visualizing facial cosmetic treatments, offering a cutting-edge, interactive user experience.

C&C Community Website

Command & Conquer Community platform with improved SEO, a sleek interface, and content integrations like Twitch and Steam, creating a hub for fans and creators.

React Native Health App

Custom Android and iOS health app developed with React Native and TypeScript, tailored for a health-tech startup, ensuring cross-platform compatibility.

Oriental Garden Restaurant - Website Redesign

Website redesign featuring an online ordering system that boosts sales and enhances customer engagement with a modern, intuitive interface.