CINXE.COM
Adding an SSH key to your account | Codeberg Documentation
<!DOCTYPE html> <html lang="en" class="codeberg-design"> <head> <title>Adding an SSH key to your account | Codeberg Documentation</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" href="https://design.codeberg.org/logo-kit/favicon.ico" type="image/x-icon"> <link rel="icon" href="https://design.codeberg.org/logo-kit/favicon.svg" type="image/svg+xml"> <link rel="apple-touch-icon" href="https://design.codeberg.org/logo-kit/apple-touch-icon.png"> <link rel="preload" type="text/css" href="/assets/css/codeberg-docs.css" as="style"> <link rel="preload" type="text/css" href="https://design.codeberg.org/design-kit/codeberg.css" as="style"> <link rel="preload" href="https://fonts.codeberg.org/dist/inter/Inter%20Web/inter.css" as="style"> <link rel="preload" href="https://fonts.codeberg.org/dist/fontawesome6/css/svg-with-js.css" as="style"> <!-- Details and License: https://codeberg.org/Codeberg/Design/src/design-kit --> <link rel="stylesheet" href="https://design.codeberg.org/design-kit/codeberg.css"> <script defer="" src="https://design.codeberg.org/design-kit/codeberg.js"></script> <link rel="stylesheet" type="text/css" href="/assets/css/codeberg-docs.css"> <!-- Syntax highlighting --> <link rel="stylesheet" type="text/css" href="/assets/css/prism-nord.css"> <!-- Details and License: https://fonts.codeberg.org/fonts/inter --> <link rel="stylesheet" type="text/css" href="https://fonts.codeberg.org/dist/inter/Inter%20Web/inter.css"> <!-- Details and License: https://fonts.codeberg.org/fonts/fontawesome5 --> <link rel="stylesheet" type="text/css" href="https://fonts.codeberg.org/dist/fontawesome6/css/svg-with-js.css"> <link href="/pagefind/pagefind-modular-ui.css" rel="stylesheet"> <script src="/pagefind/pagefind-modular-ui.js"></script> <script> window.addEventListener('DOMContentLoaded', (event) => { const instance = new PagefindModularUI.Instance(); instance.add( new PagefindModularUI.Input({ containerElement: '#search-input', }), ); instance.add( new PagefindModularUI.ResultList({ containerElement: '#search-results', }), ); document.addEventListener( 'keydown', (event) => { if (event.key == '/') { event.preventDefault(); document.getElementById('search-input').focus(); } }, false, ); }); </script> <script> // @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt CC0 document.addEventListener('DOMContentLoaded', function () { document.getElementsByClassName('active')[0].scrollIntoView({ block: 'center' }); }); // @license-end </script> </head> <body data-set-preferred-mode-onload="true"> <div class="modal" id="modal-1" tabindex="-1" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <h5 class="modal-title">LICENSE</h5> <p> The <span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/Text" property="dct:title" rel="dct:type"> Codeberg Documentation website</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>. </p> <p> It bundles third-party font software licensed under a different license. Please look at <a href="https://codeberg.org/Codeberg/Documentation/src/LICENSE.md">the LICENSE file</a> for details. </p> <p> Changes to the original versions of the article as well as its individual authors can be looked up in <a href="https://codeberg.org/Codeberg/Documentation/commits/./content/security/ssh-key.md" target="_blank" rel="noreferrer">this article's commit history</a> </p> <p>Codeberg and the Codeberg Logo are trademarks of Codeberg e.V.</p> <div class="text-right mt-20"> <a href="#" class="mr-5 btn" role="button">Close</a> </div> </div> </div> </div> <div class="with-navbar with-sidebar with-transitions page-wrapper" data-sidebar-type="overlayed-sm-and-down"> <div class="sidebar-overlay" onclick="halfmoon.toggleSidebar()"></div> <nav class="navbar"> <div class="navbar-content"> <button class="btn btn-primary" type="button" onclick="halfmoon.toggleSidebar()"> <svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="bars" class="svg-inline--fa fa-bars" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z"></path></svg> <span class="sr-only">Toggle sidebar</span> </button> </div> <!-- Navbar brand --> <a href="/" class="navbar-brand" title="Codeberg Docs"> <img src="https://design.codeberg.org/logo-kit/icon_inverted.svg" height="22" width="22" alt="Codeberg"> Docs </a> <!-- Navbar nav --> <ul class="d-md-flex ml-auto d-none navbar-nav"> <li class="nav-item"> <a href="https://codeberg.org/Codeberg/Documentation/commits/./content/security/ssh-key.md" class="nav-link" target="_blank" rel="noreferrer"> <svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="clock-rotate-left" class="svg-inline--fa fa-clock-rotate-left" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M75 75L41 41C25.9 25.9 0 36.6 0 57.9V168c0 13.3 10.7 24 24 24H134.1c21.4 0 32.1-25.9 17-41l-30.8-30.8C155 85.5 203 64 256 64c106 0 192 86 192 192s-86 192-192 192c-40.8 0-78.6-12.7-109.7-34.4c-14.5-10.1-34.4-6.6-44.6 7.9s-6.6 34.4 7.9 44.6C151.2 495 201.7 512 256 512c141.4 0 256-114.6 256-256S397.4 0 256 0C185.3 0 121.3 28.7 75 75zm181 53c-13.3 0-24 10.7-24 24V256c0 6.4 2.5 12.5 7 17l72 72c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-65-65V152c0-13.3-10.7-24-24-24z"></path></svg> View History </a> </li> <li class="nav-item"> <a href="https://codeberg.org/Codeberg/Documentation/src/./content/security/ssh-key.md" class="nav-link" target="_blank" rel="noreferrer"> <svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="code" class="svg-inline--fa fa-code" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="currentColor" d="M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6zm80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3L562.7 256l-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3z"></path></svg> View Source </a> </li> </ul> <!-- Navbar content (dropdown menu) --> <div class="ml-auto d-md-none navbar-content"> <div class="with-arrow dropdown"> <button class="btn" data-toggle="dropdown" type="button" id="navbar-dropdown-toggle-btn-1"> Menu <svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="angle-down" class="svg-inline--fa fa-angle-down" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M201.4 342.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 274.7 86.6 137.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z"></path></svg> </button> <div class="dropdown-menu-right w-200 dropdown-menu" aria-labelledby="navbar-dropdown-toggle-btn-1"> <a href="https://codeberg.org/Codeberg/Documentation/commits/./content/security/ssh-key.md" class="dropdown-item" target="_blank" rel="noreferrer"> <svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="clock-rotate-left" class="svg-inline--fa fa-clock-rotate-left" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M75 75L41 41C25.9 25.9 0 36.6 0 57.9V168c0 13.3 10.7 24 24 24H134.1c21.4 0 32.1-25.9 17-41l-30.8-30.8C155 85.5 203 64 256 64c106 0 192 86 192 192s-86 192-192 192c-40.8 0-78.6-12.7-109.7-34.4c-14.5-10.1-34.4-6.6-44.6 7.9s-6.6 34.4 7.9 44.6C151.2 495 201.7 512 256 512c141.4 0 256-114.6 256-256S397.4 0 256 0C185.3 0 121.3 28.7 75 75zm181 53c-13.3 0-24 10.7-24 24V256c0 6.4 2.5 12.5 7 17l72 72c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-65-65V152c0-13.3-10.7-24-24-24z"></path></svg> View History </a> <a href="https://codeberg.org/Codeberg/Documentation/src/./content/security/ssh-key.md" class="dropdown-item" target="_blank" rel="noreferrer"> <svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="code" class="svg-inline--fa fa-code" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="currentColor" d="M392.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6zm80.6 120.1c-12.5 12.5-12.5 32.8 0 45.3L562.7 256l-89.4 89.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l112-112c12.5-12.5 12.5-32.8 0-45.3l-112-112c-12.5-12.5-32.8-12.5-45.3 0zm-306.7 0c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3l112 112c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l89.4-89.4c12.5-12.5 12.5-32.8 0-45.3z"></path></svg> View Source </a> <div class="mt-5 dropdown-divider"></div> </div> </div> </div> </nav> <div class="sidebar"> <div class="sidebar-menu"> <!-- Sidebar content with the search box --> <div class="sidebar-content"> <input type="text" class="form-control" placeholder="Filter Docs" id="search-input"> <div class="mt-10 font-size-12">Press <kbd>/</kbd> to focus</div> <div id="search-results"></div> </div> <h5 class="sidebar-title "> <a href="/" id=""><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="caret-right" class="svg-inline--fa fa-caret-right" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 512"><path fill="currentColor" d="M246.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-128-128c-9.2-9.2-22.9-11.9-34.9-6.9s-19.8 16.6-19.8 29.6l0 256c0 12.9 7.8 24.6 19.8 29.6s25.7 2.2 34.9-6.9l128-128z"></path></svg> Codeberg Documentation</a> </h5> <div class="sidebar-divider"></div> <br> <h5 class="sidebar-title "> <a href="/getting-started/" id="GettingStarted"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="rocket" class="svg-inline--fa fa-rocket" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M156.6 384.9L125.7 354c-8.5-8.5-11.5-20.8-7.7-32.2c3-8.9 7-20.5 11.8-33.8L24 288c-8.6 0-16.6-4.6-20.9-12.1s-4.2-16.7 .2-24.1l52.5-88.5c13-21.9 36.5-35.3 61.9-35.3l82.3 0c2.4-4 4.8-7.7 7.2-11.3C289.1-4.1 411.1-8.1 483.9 5.3c11.6 2.1 20.6 11.2 22.8 22.8c13.4 72.9 9.3 194.8-111.4 276.7c-3.5 2.4-7.3 4.8-11.3 7.2v82.3c0 25.4-13.4 49-35.3 61.9l-88.5 52.5c-7.4 4.4-16.6 4.5-24.1 .2s-12.1-12.2-12.1-20.9V380.8c-14.1 4.9-26.4 8.9-35.7 11.9c-11.2 3.6-23.4 .5-31.8-7.8zM384 168a40 40 0 1 0 0-80 40 40 0 1 0 0 80z"></path></svg> Getting Started with Codeberg</a> </h5> <div class="sidebar-divider"></div> <a href="/getting-started/what-is-codeberg/" class="sidebar-link" id="WhatIsCodeberg"> <span class="name">What is Codeberg?</span> </a> <a href="/getting-started/first-steps/" class="sidebar-link" id="FirstSteps"> <span class="name">Your First Steps on Codeberg</span> </a> <a href="/getting-started/install-git/" class="sidebar-link" id="InstallGit"> <span class="name">Install Git</span> </a> <a href="/getting-started/first-repository/" class="sidebar-link" id="FirstRepository"> <span class="name">Your First Repository</span> </a> <a href="/getting-started/issue-tracking-basics/" class="sidebar-link" id="IssueTrackingBasics"> <span class="name">The Basics of Issue Tracking</span> </a> <a href="/getting-started/wiki/" class="sidebar-link" id="Wiki"> <span class="name">Integrated Wiki</span> </a> <a href="/getting-started/email-settings/" class="sidebar-link" id="CommunicationCodeberg"> <span class="name">Email Settings</span> </a> <a href="/getting-started/licensing/" class="sidebar-link" id="LicensingOnCodeberg"> <span class="name">Licensing on Codeberg</span> </a> <a href="/getting-started/faq/" class="sidebar-link" id="FAQ"> <span class="name">Frequently Asked Questions</span> </a> <br> <h5 class="sidebar-title "> <a href="/collaborating/" id="Collaborating"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="user-group" class="svg-inline--fa fa-user-group" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="currentColor" d="M96 128a128 128 0 1 1 256 0A128 128 0 1 1 96 128zM0 482.3C0 383.8 79.8 304 178.3 304h91.4C368.2 304 448 383.8 448 482.3c0 16.4-13.3 29.7-29.7 29.7H29.7C13.3 512 0 498.7 0 482.3zM609.3 512H471.4c5.4-9.4 8.6-20.3 8.6-32v-8c0-60.7-27.1-115.2-69.8-151.8c2.4-.1 4.7-.2 7.1-.2h61.4C567.8 320 640 392.2 640 481.3c0 17-13.8 30.7-30.7 30.7zM432 256c-31 0-59-12.6-79.3-32.9C372.4 196.5 384 163.6 384 128c0-26.8-6.6-52.1-18.3-74.3C384.3 40.1 407.2 32 432 32c61.9 0 112 50.1 112 112s-50.1 112-112 112z"></path></svg> Collaborating with Others</a> </h5> <div class="sidebar-divider"></div> <a href="/collaborating/citable-code/" class="sidebar-link" id="CitableCode"> <span class="name">Citable Code</span> </a> <a href="/collaborating/pull-requests-and-git-flow/" class="sidebar-link" id="PullRequestsGitFlow"> <span class="name">Pull requests and Git flow</span> </a> <a href="/collaborating/invite-collaborators/" class="sidebar-link" id="InviteCollaborators"> <span class="name">Invite Collaborators</span> </a> <a href="/collaborating/create-organization/" class="sidebar-link" id="CreateOrganization"> <span class="name">Create and Manage an Organization</span> </a> <a href="/collaborating/repo-permissions/" class="sidebar-link" id="RepositoryPermissions"> <span class="name">Repository Permissions</span> </a> <a href="/collaborating/resolve-conflicts/" class="sidebar-link" id="ResolveConflicts"> <span class="name">Resolve Conflicts</span> </a> <br> <h5 class="sidebar-title "> <a href="/git/" id="Git"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="code-branch" class="svg-inline--fa fa-code-branch" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M80 104a24 24 0 1 0 0-48 24 24 0 1 0 0 48zm80-24c0 32.8-19.7 61-48 73.3v87.8c18.8-10.9 40.7-17.1 64-17.1h96c35.3 0 64-28.7 64-64v-6.7C307.7 141 288 112.8 288 80c0-44.2 35.8-80 80-80s80 35.8 80 80c0 32.8-19.7 61-48 73.3V160c0 70.7-57.3 128-128 128H176c-35.3 0-64 28.7-64 64v6.7c28.3 12.3 48 40.5 48 73.3c0 44.2-35.8 80-80 80s-80-35.8-80-80c0-32.8 19.7-61 48-73.3V352 153.3C19.7 141 0 112.8 0 80C0 35.8 35.8 0 80 0s80 35.8 80 80zm232 0a24 24 0 1 0 -48 0 24 24 0 1 0 48 0zM80 456a24 24 0 1 0 0-48 24 24 0 1 0 0 48z"></path></svg> Working with Git Repositories</a> </h5> <div class="sidebar-divider"></div> <a href="/git/git-ignore/" class="sidebar-link" id="UsingGitIgnore"> <span class="name">Using .gitignore</span> </a> <a href="/git/configuring-git/" class="sidebar-link" id="ConfiguringGit"> <span class="name">Configuring Git</span> </a> <a href="/git/clone-commit-via-cli/" class="sidebar-link" id="CloneCommitviaCLI"> <span class="name">Clone & Commit via CLI</span> </a> <a href="/git/clone-commit-via-web/" class="sidebar-link" id="CloneCommitViaWeb"> <span class="name">Clone & Commit via Web</span> </a> <a href="/git/squash-commits/" class="sidebar-link" id="SquashCommits"> <span class="name">Merge multiple commits into one</span> </a> <a href="/git/using-tags/" class="sidebar-link" id="UsingTags"> <span class="name">Tags and Releases</span> </a> <a href="/git/using-lfs/" class="sidebar-link" id="UsingLFS"> <span class="name">Working with large files</span> </a> <br> <h5 class="sidebar-title "> <a href="/markdown/" id="Markdown"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="pen-nib" class="svg-inline--fa fa-pen-nib" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M368.4 18.3L312.7 74.1 437.9 199.3l55.7-55.7c21.9-21.9 21.9-57.3 0-79.2L447.6 18.3c-21.9-21.9-57.3-21.9-79.2 0zM288 94.6l-9.2 2.8L134.7 140.6c-19.9 6-35.7 21.2-42.3 41L3.8 445.8c-3.8 11.3-1 23.9 7.3 32.4L164.7 324.7c-3-6.3-4.7-13.3-4.7-20.7c0-26.5 21.5-48 48-48s48 21.5 48 48s-21.5 48-48 48c-7.4 0-14.4-1.7-20.7-4.7L33.7 500.9c8.6 8.3 21.1 11.2 32.4 7.3l264.3-88.6c19.7-6.6 35-22.4 41-42.3l43.2-144.1 2.8-9.2L288 94.6z"></path></svg> Writing in Markdown</a> </h5> <div class="sidebar-divider"></div> <a href="/markdown/introduction-to-markdown/" class="sidebar-link" id="IntroductionToMarkdown"> <span class="name">Introduction to Markdown</span> </a> <a href="/markdown/using-links/" class="sidebar-link" id="UsingLinks"> <span class="name">Using Links</span> </a> <a href="/markdown/topics/" class="sidebar-link" id="Topics"> <span class="name">Topics</span> </a> <a href="/markdown/preformatted-text/" class="sidebar-link" id="PreformattedText"> <span class="name">Preformatted Text</span> </a> <a href="/markdown/using-lists/" class="sidebar-link" id="UsingLists"> <span class="name">Using Lists</span> </a> <a href="/markdown/using-images/" class="sidebar-link" id="UsingImages"> <span class="name">Using Images</span> </a> <a href="/markdown/tables-in-markdown/" class="sidebar-link" id="TablesInMarkdown"> <span class="name">Tables in Markdown</span> </a> <a href="/markdown/faq/" class="sidebar-link" id="MarkdownFAQ"> <span class="name">Markdown FAQ</span> </a> <br> <h5 class="sidebar-title active"> <a href="/security/" id="Security"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="lock" class="svg-inline--fa fa-lock" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M144 144v48H304V144c0-44.2-35.8-80-80-80s-80 35.8-80 80zM80 192V144C80 64.5 144.5 0 224 0s144 64.5 144 144v48h16c35.3 0 64 28.7 64 64V448c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V256c0-35.3 28.7-64 64-64H80z"></path></svg> Security</a> </h5> <div class="sidebar-divider"></div> <a href="/security/2fa/" class="sidebar-link" id="2FA"> <span class="name">Setting up two-factor authentication</span> </a> <a href="/security/ssh-key/" class="sidebar-link active" id="SSHKey"> <span class="name">Adding an SSH key to your account</span> </a> <a href="/security/ssh-fingerprint/" class="sidebar-link" id="SSHFingerprint"> <span class="name">Verifying you're connected to Codeberg using SSH fingerprints</span> </a> <a href="/security/gpg-key/" class="sidebar-link" id="GPGKey"> <span class="name">Adding a GPG key to your account</span> </a> <br> <h5 class="sidebar-title "> <a href="/codeberg-pages/" id="CodebergPages"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="server" class="svg-inline--fa fa-server" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M64 32C28.7 32 0 60.7 0 96v64c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64zm280 72a24 24 0 1 1 0 48 24 24 0 1 1 0-48zm48 24a24 24 0 1 1 48 0 24 24 0 1 1 -48 0zM64 288c-35.3 0-64 28.7-64 64v64c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V352c0-35.3-28.7-64-64-64H64zm280 72a24 24 0 1 1 0 48 24 24 0 1 1 0-48zm56 24a24 24 0 1 1 48 0 24 24 0 1 1 -48 0z"></path></svg> Codeberg Pages</a> </h5> <div class="sidebar-divider"></div> <a href="/codeberg-pages/using-custom-domain/" class="sidebar-link" id="UsingCustomDomains"> <span class="name">Using Custom Domains</span> </a> <a href="/codeberg-pages/troubleshooting/" class="sidebar-link" id="Troubleshooting"> <span class="name">Troubleshooting</span> </a> <a href="/codeberg-pages/examples/docs-as-code/" class="sidebar-link" id="DocsAsCode"> <span class="name">Example: Docs as Code with Sphinx</span> </a> <a href="/codeberg-pages/pushing-output/" class="sidebar-link" id="PushingOutput"> <span class="name">Pushing output from SSGs into Codeberg Pages</span> </a> <a href="/codeberg-pages/redirects/" class="sidebar-link" id="Redirects"> <span class="name">Redirects</span> </a> <br> <h5 class="sidebar-title "> <a href="/advanced/" id="AdvancedUsage"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="terminal" class="svg-inline--fa fa-terminal" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path fill="currentColor" d="M9.4 86.6C-3.1 74.1-3.1 53.9 9.4 41.4s32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L178.7 256 9.4 86.6zM256 416H544c17.7 0 32 14.3 32 32s-14.3 32-32 32H256c-17.7 0-32-14.3-32-32s14.3-32 32-32z"></path></svg> Advanced Usage</a> </h5> <div class="sidebar-divider"></div> <a href="/advanced/access-token/" class="sidebar-link" id="AccessToken"> <span class="name">Generating an Access Token</span> </a> <a href="/advanced/migrating-repos/" class="sidebar-link" id="MigratingRepos"> <span class="name">Migrating Repositories</span> </a> <a href="/advanced/using-webhooks/" class="sidebar-link" id="UsingWebhooks"> <span class="name">Using Webhooks</span> </a> <br> <h5 class="sidebar-title "> <a href="/ci/" id="CI"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="arrows-spin" class="svg-inline--fa fa-arrows-spin" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M256 96c38.4 0 73.7 13.5 101.3 36.1l-32.6 32.6c-4.6 4.6-5.9 11.5-3.5 17.4s8.3 9.9 14.8 9.9H448c8.8 0 16-7.2 16-16V64c0-6.5-3.9-12.3-9.9-14.8s-12.9-1.1-17.4 3.5l-34 34C363.4 52.6 312.1 32 256 32c-10.9 0-21.5 .8-32 2.3V99.2c10.3-2.1 21-3.2 32-3.2zM132.1 154.7l32.6 32.6c4.6 4.6 11.5 5.9 17.4 3.5s9.9-8.3 9.9-14.8V64c0-8.8-7.2-16-16-16H64c-6.5 0-12.3 3.9-14.8 9.9s-1.1 12.9 3.5 17.4l34 34C52.6 148.6 32 199.9 32 256c0 10.9 .8 21.5 2.3 32H99.2c-2.1-10.3-3.2-21-3.2-32c0-38.4 13.5-73.7 36.1-101.3zM477.7 224H412.8c2.1 10.3 3.2 21 3.2 32c0 38.4-13.5 73.7-36.1 101.3l-32.6-32.6c-4.6-4.6-11.5-5.9-17.4-3.5s-9.9 8.3-9.9 14.8V448c0 8.8 7.2 16 16 16H448c6.5 0 12.3-3.9 14.8-9.9s1.1-12.9-3.5-17.4l-34-34C459.4 363.4 480 312.1 480 256c0-10.9-.8-21.5-2.3-32zM256 416c-38.4 0-73.7-13.5-101.3-36.1l32.6-32.6c4.6-4.6 5.9-11.5 3.5-17.4s-8.3-9.9-14.8-9.9H64c-8.8 0-16 7.2-16 16l0 112c0 6.5 3.9 12.3 9.9 14.8s12.9 1.1 17.4-3.5l34-34C148.6 459.4 199.9 480 256 480c10.9 0 21.5-.8 32-2.3V412.8c-10.3 2.1-21 3.2-32 3.2z"></path></svg> Working with Codeberg's CI</a> </h5> <div class="sidebar-divider"></div> <a href="/ci/actions/" class="sidebar-link" id="UsingForgejoActions"> <span class="name">Using Forgejo Actions (Self-hosted)</span> </a> <br> <h5 class="sidebar-title "> <a href="/integrations/" id="Integrations"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="puzzle-piece" class="svg-inline--fa fa-puzzle-piece" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M192 104.8c0-9.2-5.8-17.3-13.2-22.8C167.2 73.3 160 61.3 160 48c0-26.5 28.7-48 64-48s64 21.5 64 48c0 13.3-7.2 25.3-18.8 34c-7.4 5.5-13.2 13.6-13.2 22.8v0c0 12.8 10.4 23.2 23.2 23.2H336c26.5 0 48 21.5 48 48v56.8c0 12.8 10.4 23.2 23.2 23.2v0c9.2 0 17.3-5.8 22.8-13.2c8.7-11.6 20.7-18.8 34-18.8c26.5 0 48 28.7 48 64s-21.5 64-48 64c-13.3 0-25.3-7.2-34-18.8c-5.5-7.4-13.6-13.2-22.8-13.2v0c-12.8 0-23.2 10.4-23.2 23.2V464c0 26.5-21.5 48-48 48H279.2c-12.8 0-23.2-10.4-23.2-23.2v0c0-9.2 5.8-17.3 13.2-22.8c11.6-8.7 18.8-20.7 18.8-34c0-26.5-28.7-48-64-48s-64 21.5-64 48c0 13.3 7.2 25.3 18.8 34c7.4 5.5 13.2 13.6 13.2 22.8v0c0 12.8-10.4 23.2-23.2 23.2H48c-26.5 0-48-21.5-48-48V343.2C0 330.4 10.4 320 23.2 320v0c9.2 0 17.3 5.8 22.8 13.2C54.7 344.8 66.7 352 80 352c26.5 0 48-28.7 48-64s-21.5-64-48-64c-13.3 0-25.3 7.2-34 18.8C40.5 250.2 32.4 256 23.2 256v0C10.4 256 0 245.6 0 232.8V176c0-26.5 21.5-48 48-48H168.8c12.8 0 23.2-10.4 23.2-23.2v0z"></path></svg> Integrations with Other Services</a> </h5> <div class="sidebar-divider"></div> <a href="/integrations/keycloak/" class="sidebar-link" id="KeycloakIntegration"> <span class="name">Integrating with Keycloak</span> </a> <a href="/integrations/liberapay/" class="sidebar-link" id="Liberapay"> <span class="name">Integrating with LiberaPay</span> </a> <a href="/integrations/matrix/" class="sidebar-link" id="MatrixIntegration"> <span class="name">Integrating with Matrix</span> </a> <a href="/integrations/read-the-docs/" class="sidebar-link" id="Read the Docs Integration"> <span class="name">Integrating with Read the Docs</span> </a> <br> <h5 class="sidebar-title "> <a href="/codeberg-translate/" id="CodebergTranslate"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="language" class="svg-inline--fa fa-language" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="currentColor" d="M0 128C0 92.7 28.7 64 64 64H256h48 16H576c35.3 0 64 28.7 64 64V384c0 35.3-28.7 64-64 64H320 304 256 64c-35.3 0-64-28.7-64-64V128zm320 0V384H576V128H320zM178.3 175.9c-3.2-7.2-10.4-11.9-18.3-11.9s-15.1 4.7-18.3 11.9l-64 144c-4.5 10.1 .1 21.9 10.2 26.4s21.9-.1 26.4-10.2l8.9-20.1h73.6l8.9 20.1c4.5 10.1 16.3 14.6 26.4 10.2s14.6-16.3 10.2-26.4l-64-144zM160 233.2L179 276H141l19-42.8zM448 164c11 0 20 9 20 20v4h44 16c11 0 20 9 20 20s-9 20-20 20h-2l-1.6 4.5c-8.9 24.4-22.4 46.6-39.6 65.4c.9 .6 1.8 1.1 2.7 1.6l18.9 11.3c9.5 5.7 12.5 18 6.9 27.4s-18 12.5-27.4 6.9l-18.9-11.3c-4.5-2.7-8.8-5.5-13.1-8.5c-10.6 7.5-21.9 14-34 19.4l-3.6 1.6c-10.1 4.5-21.9-.1-26.4-10.2s.1-21.9 10.2-26.4l3.6-1.6c6.4-2.9 12.6-6.1 18.5-9.8l-12.2-12.2c-7.8-7.8-7.8-20.5 0-28.3s20.5-7.8 28.3 0l14.6 14.6 .5 .5c12.4-13.1 22.5-28.3 29.8-45H448 376c-11 0-20-9-20-20s9-20 20-20h52v-4c0-11 9-20 20-20z"></path></svg> Codeberg Translate</a> </h5> <div class="sidebar-divider"></div> <a href="/codeberg-translate/introduction-to-weblate/" class="sidebar-link" id="WeblateIntroduction"> <span class="name">Introduction to Weblate</span> </a> <a href="/codeberg-translate/manual-component-configuration/" class="sidebar-link" id="CodebergTranslateManualComponentConfiguration"> <span class="name">Manual Component configuration</span> </a> <a href="/codeberg-translate/getting-started/" class="sidebar-link" id="CodebergTranslateGettingStarted"> <span class="name">Getting started</span> </a> <br> <h5 class="sidebar-title "> <a href="/improving-codeberg/" id="ImprovingCodeberg"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="handshake-angle" class="svg-inline--fa fa-handshake-angle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path fill="currentColor" d="M544 248v3.3l69.7-69.7c21.9-21.9 21.9-57.3 0-79.2L535.6 24.4c-21.9-21.9-57.3-21.9-79.2 0L416.3 64.5c-2.7-.3-5.5-.5-8.3-.5H296c-37.1 0-67.6 28-71.6 64H224V248c0 22.1 17.9 40 40 40s40-17.9 40-40V176c0 0 0-.1 0-.1V160l16 0 136 0c0 0 0 0 .1 0H464c44.2 0 80 35.8 80 80v8zM336 192v56c0 39.8-32.2 72-72 72s-72-32.2-72-72V129.4c-35.9 6.2-65.8 32.3-76 68.2L99.5 255.2 26.3 328.4c-21.9 21.9-21.9 57.3 0 79.2l78.1 78.1c21.9 21.9 57.3 21.9 79.2 0l37.7-37.7c.9 0 1.8 .1 2.7 .1H384c26.5 0 48-21.5 48-48c0-5.6-1-11-2.7-16H432c26.5 0 48-21.5 48-48c0-12.8-5-24.4-13.2-33c25.7-5 45.1-27.6 45.2-54.8v-.4c-.1-30.8-25.1-55.8-56-55.8c0 0 0 0 0 0l-120 0z"></path></svg> Improving Codeberg</a> </h5> <div class="sidebar-divider"></div> <a href="/improving-codeberg/contributing-code/" class="sidebar-link" id="ContributingCode"> <span class="name">Contributing Code</span> </a> <a href="/improving-codeberg/donate/" class="sidebar-link" id="Donate"> <span class="name">Donating to Codeberg</span> </a> <br> <h5 class="sidebar-title "> <a href="/improving-documentation/" id="ImprovingTheDocumentation"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="book" class="svg-inline--fa fa-book" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M96 0C43 0 0 43 0 96V416c0 53 43 96 96 96H384h32c17.7 0 32-14.3 32-32s-14.3-32-32-32V384c17.7 0 32-14.3 32-32V32c0-17.7-14.3-32-32-32H384 96zm0 384H352v64H96c-17.7 0-32-14.3-32-32s14.3-32 32-32zm32-240c0-8.8 7.2-16 16-16H336c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16zm16 48H336c8.8 0 16 7.2 16 16s-7.2 16-16 16H144c-8.8 0-16-7.2-16-16s7.2-16 16-16z"></path></svg> Improving the Documentation</a> </h5> <div class="sidebar-divider"></div> <a href="/improving-documentation/style-guide/" class="sidebar-link" id="StyleGuide"> <span class="name">Style Guide</span> </a> <a href="/improving-documentation/create-article/" class="sidebar-link" id="CreateANewArticle"> <span class="name">How to create a new article?</span> </a> <a href="/improving-documentation/preview/" class="sidebar-link" id="PreviewArticle"> <span class="name">Can I preview my article?</span> </a> <a href="/improving-documentation/screenshots/" class="sidebar-link" id="HowToMakeScreenshots"> <span class="name">How to make screenshots for Codeberg Documentation?</span> </a> <a href="/improving-documentation/docs-contributor-faq/" class="sidebar-link" id="DocsContributorFAQ"> <span class="name">Documentation Contributor FAQ</span> </a> <br> <h5 class="sidebar-title "> <a href="/contact/" id="Contact"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="envelope" class="svg-inline--fa fa-envelope" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M48 64C21.5 64 0 85.5 0 112c0 15.1 7.1 29.3 19.2 38.4L236.8 313.6c11.4 8.5 27 8.5 38.4 0L492.8 150.4c12.1-9.1 19.2-23.3 19.2-38.4c0-26.5-21.5-48-48-48H48zM0 176V384c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V176L294.4 339.2c-22.8 17.1-54 17.1-76.8 0L0 176z"></path></svg> Contact</a> </h5> <div class="sidebar-divider"></div> <br> </div> </div> <div class="content-wrapper"> <div class="container-fluid"> <div class="row"> <div class="col-xl-8 content" data-pagefind-body=""> <h1 class="content-title font-size-24">Adding an SSH key to your account</h1> <nav class="mb-3 d-xl-none" data-pagefind-ignore="all"> <details class="collapse-panel"> <summary class="d-block d-flex justify-content-between align-items-center py-2 w-full collapse-header"> <span class="antialiased">On this page</span> </summary> <div id="toc" class="collapse-content"> <ol><li><a class="sidebar-link" href="#generating-an-ssh-key-pair">Generating an SSH key pair</a><ol><li><a class="sidebar-link" href="#fido2-with-openssh">FIDO2 with OpenSSH</a></li></ol></li> <li><a class="sidebar-link" href="#add-the-ssh-key-to-codeberg">Add the SSH key to Codeberg</a></li> <li><a class="sidebar-link" href="#test-the-ssh-connection">Test the SSH connection</a></li> <li><a class="sidebar-link" href="#verifying-your-ssh-key">Verifying your SSH Key</a></li> <li><a class="sidebar-link" href="#telling-git-about-your-ssh-key">Telling Git about your SSH key</a></li> <li><a class="sidebar-link" href="#avoid-re-typing-the-passphrase">Avoid re-typing the passphrase</a></li> <li><a class="sidebar-link" href="#changing-your-repository's-transport-from-https-to-ssh">Changing your repository's transport from HTTPS to SSH</a></li></ol> </div> </details> </nav> <p>It is recommended to use one key per client. This means that if you access your Codeberg repository from your home PC, your laptop and your office PC you should generate separate keys for each machine.</p> <h2 class="content-title" id="generating-an-ssh-key-pair" tabindex="-1"><a class="header-anchor" href="#generating-an-ssh-key-pair">Generating an SSH key pair</a></h2> <ol> <li> <p>Open Terminal on Linux/macOS, or Git Bash on Windows.</p> </li> <li> <p>Paste the text below:</p> <pre class="language-shell"><code class="language-shell">ssh-keygen <span class="token parameter variable">-t</span> ed25519 <span class="token parameter variable">-a</span> <span class="token number">100</span></code></pre> <p>This will generate a new SSH key. You can also add a comment to help you identify the client with <code>-C "comment here"</code>.</p> <pre class="language-shell"><code class="language-shell"><span class="token operator">></span> Generating public/private ed25519 key pair.</code></pre> </li> <li> <p>When you're prompted to "Enter a file in which to save the key", press <kbd>Enter</kbd>. This accepts the default file location:</p> <pre class="language-shell"><code class="language-shell"><span class="token operator">></span> Enter <span class="token function">file</span> <span class="token keyword">in</span> <span class="token function">which</span> to save the key <span class="token punctuation">(</span>/home/knut/.ssh/id_ed25519<span class="token punctuation">)</span>: <span class="token punctuation">[</span>Press enter<span class="token punctuation">]</span></code></pre> <p>If you see that <code>/home/knut/.ssh/id_ed25519 already exists</code>, follow these steps:</p> <ol> <li> <p>When prompted to overwrite the existing file, type <kbd>n</kbd> to choose not to overwrite.</p> </li> <li> <p>Afterward, re-run the same command:</p> <pre class="language-shell"><code class="language-shell">ssh-keygen <span class="token parameter variable">-t</span> ed25519 <span class="token parameter variable">-a</span> <span class="token number">100</span></code></pre> </li> <li> <p>This time, enter a new filepath when prompted (e.g., <code>~/.ssh/id_ed25519_codeberg</code>) to avoid overwriting the existing key.</p> </li> </ol> </li> <li> <p>You will be asked for a passphrase; enter one if you'd like, or leave the prompt empty.</p> </li> </ol> <p>Your private key can be protected by a passphrase. This adds a layer of authentication that increases security. Be aware that this will only be helpful for certain attack scenarios and does not offer 100% protection. It is recommended to keep your private key safe and - well - private.</p> <h3 class="content-title" id="fido2-with-openssh" tabindex="-1"><a class="header-anchor" href="#fido2-with-openssh">FIDO2 with OpenSSH</a></h3> <ol> <li> <p>Connect your security key and open a terminal</p> </li> <li> <p>Paste the text below</p> <pre class="language-shell"><code class="language-shell">ssh-keygen <span class="token parameter variable">-t</span> ed25519-sk</code></pre> </li> <li> <p>If you have set one on your key, you'll be prompted for your FIDO2 PIN. Enter it to continue</p> </li> <li> <p>When you're prompted to "Enter a file in which to save the key", press <kbd>Enter</kbd>. This accepts the default file location.</p> </li> <li> <p>You will be asked for a passphrase; enter one if you'd like, or leave the prompt empty.</p> </li> </ol> <p>Keep in mind that now, every time you wish to use Codeberg over SSH, you must have your security key plugged in and will be prompted to touch it to continue.</p> <h2 class="content-title" id="add-the-ssh-key-to-codeberg" tabindex="-1"><a class="header-anchor" href="#add-the-ssh-key-to-codeberg">Add the SSH key to Codeberg</a></h2> <ol> <li> <p>Copy the SSH key to your clipboard. You must only copy the public key not the private one. You can identify it by the <code>.pub</code> suffix. By default, you can find the public key in <code>$HOME/.ssh/id_ed25519.pub</code>.</p> <p>On Linux you can use <code>xclip</code> on the command line. You may need to install it from your package manager.</p> <pre class="language-shell"><code class="language-shell">$ xclip <span class="token parameter variable">-selection</span> clipboard <span class="token operator"><</span> ~/.ssh/id_ed25519.pub</code></pre> <p>On Windows you can use <code>clip</code>.</p> <pre class="language-shell"><code class="language-shell">$ clip <span class="token operator"><</span> ~/.ssh/id_ed25519.pub</code></pre> <p>On macOS you can use <code>pbcopy</code>.</p> <pre class="language-shell"><code class="language-shell">$ pbcopy <span class="token operator"><</span> ~/.ssh/id_ed25519.pub</code></pre> <p>These commands will copy the contents of id_ed25519.pub (your SSH public key) to your clipboard.</p> <blockquote class="alert"> <p>Alternatively you can locate the hidden .ssh folder, open the file in your favorite text editor, and copy it to your clipboard.</p> </blockquote> </li> <li> <p>Navigate to your user settings</p> </li> </ol> <picture><source type="image/webp" srcset="/img/woKzXPidVH-1244.webp 1244w"><source type="image/png" srcset="/img/woKzXPidVH-1244.png 1244w"><img loading="lazy" decoding="async" src="/img/woKzXPidVH-1244.jpeg" alt="User Settings" width="1244" height="496"></picture> <ol start="3"> <li>Go to the section <strong>SSH / GPG Keys</strong> and click on <strong>Add key</strong>.</li> </ol> <picture><source type="image/webp" srcset="/img/tZoZzMNIMJ-1441.webp 1441w"><img loading="lazy" decoding="async" src="/img/tZoZzMNIMJ-1441.png" alt="SSH Key Settings" width="1441" height="650"></picture> <ol start="4"> <li>Give an appropriate name for the key.</li> <li>Paste your key string into <strong>Content</strong> field.</li> <li>Click the <strong>Add key</strong> button.</li> </ol> <blockquote class="alert"> <p>You can always access your SSH public keys from <code>https://codeberg.org/username.keys</code>, substituting in your Codeberg username.</p> </blockquote> <h2 class="content-title" id="test-the-ssh-connection" tabindex="-1"><a class="header-anchor" href="#test-the-ssh-connection">Test the SSH connection</a></h2> <p>If you are using a custom path, add an entry in your <code>$HOME/.ssh/config</code> file:</p> <pre class="language-config"><code class="language-config">Host codeberg.org HostName codeberg.org User git IdentityFile ~/.ssh/id_ed25519_codeberg</code></pre> <p>Do this simple test:</p> <pre class="language-shell"><code class="language-shell">$ <span class="token function">ssh</span> <span class="token parameter variable">-T</span> git@codeberg.org</code></pre> <p>The output should look like this:</p> <pre class="language-text"><code class="language-text">Hi there, ____! You've successfully authenticated with the key named ____, but Forgejo does not provide shell access. If this is unexpected, please log in with password and setup Forgejo under another user.</code></pre> <p><em>Note: All Codeberg users share a single Unix user named <code>git</code> which is used to check out repositories. Depending on the key provided, permission is granted or denied. You can check out all repositories with your key which you have permission for. You can push code to all repositories where you have write access.</em></p> <h2 class="content-title" id="verifying-your-ssh-key" tabindex="-1"><a class="header-anchor" href="#verifying-your-ssh-key">Verifying your SSH Key</a></h2> <p>Anyone can add a random SSH key; but fortunately, Codeberg provides a mechanism to verify that the key belongs to you. Every keypair consists of a public and a private key that are connected to one another. Using this private key, you can sign the provided message. If the signed message is valid, Codeberg can confirm that the added key is yours.</p> <ol> <li>Go to the <a href="https://codeberg.org/user/settings/keys">SSH/GPG Keys tab</a> in your Codeberg settings.</li> <li>Click on the <strong>Verify</strong> button next to the SSH key you would like to verify.</li> <li>Codeberg will show a token. Under its text box copy the command, and replace <code>/path_to_your_private_key</code> with the correct path of your private key.</li> <li>Copy the output, beginning with <code>-----BEGIN SSH SIGNATURE-----</code> and ending with <code>-----END SSH SIGNATURE-----</code>.</li> <li>Paste it into the large textbox and click the <strong>Verify</strong> button.</li> </ol> <h2 class="content-title" id="telling-git-about-your-ssh-key" tabindex="-1"><a class="header-anchor" href="#telling-git-about-your-ssh-key">Telling Git about your SSH key</a></h2> <p>SSH can also be used to sign commits as an alternative for GPG. You can read more about GPG commit signing <a href="/security/gpg-key">here</a>.</p> <div class="admonition note"> <div class="admonition-title"> <span class="admonition-icon note"></span> Note </div> <div class="admonition-content"> <p>SSH commit signing is available in Git 2.34 or later. To update your version of Git, see the <a href="https://git-scm.com/downloads">Git</a> website.</p> </div> </div> <ol> <li>Open your terminal.</li> <li>Type <code>git config --global gpg.format ssh</code>.</li> <li>Type <code>git config --global user.signingKey <PATH TO PUBLIC SSH KEY></code>, substituting <code><PATH TO PUBLIC SSH KEY></code> with the path to the public key you'd like to use, for example <em>~/.ssh/id_ed25519.pub</em>.</li> <li>Type <code>git config --global commit.gpgSign true</code>.</li> </ol> <h2 class="content-title" id="avoid-re-typing-the-passphrase" tabindex="-1"><a class="header-anchor" href="#avoid-re-typing-the-passphrase">Avoid re-typing the passphrase</a></h2> <p>Assuming you've created a secure key with a passphrase, SSH will prompt you for your passphrase for every connection. Common desktop environments like macOS or GNOME will offer you to cache your passphrase via an SSH agent.</p> <p>If you are working at the command line, you can alternatively do this directly:</p> <pre class="language-shell"><code class="language-shell">$ <span class="token builtin class-name">eval</span> <span class="token variable"><span class="token variable">$(</span>ssh-agent<span class="token variable">)</span></span> $ ssh-add <span class="token comment"># enter your passphrase once, then it is cached.</span></code></pre> <h2 class="content-title" id="changing-your-repository's-transport-from-https-to-ssh" tabindex="-1"><a class="header-anchor" href="#changing-your-repository's-transport-from-https-to-ssh">Changing your repository's transport from HTTPS to SSH</a></h2> <ol> <li> <p>Go to the directory where your repository is located:</p> <pre><code>cd /path/to/repository </code></pre> </li> <li> <p>Look at the existing remotes with <code>git remote</code> :</p> <pre><code>git remote -v </code></pre> <p>It will look similar to this:</p> <pre><code>origin https://codeberg.org/knut/foobar.git (fetch) origin https://codeberg.org/knut/foobar.git (push) </code></pre> <p>You might be using a different name than <code>origin</code> for your repository. If you do, remember to use that different name in the following steps.</p> </li> <li> <p>Run <code>git remote set-url</code> command followed by the remote name and the remote鈥檚 URL:</p> <pre><code>git remote set-url <remote-name> <remote-url> </code></pre> <p>For example, to change the URL of <code>origin</code> to <code>git@codeberg.org:knut/foobar.git</code> you would type:</p> <pre><code>git remote set-url origin git@codeberg.org:knut/foobar.git </code></pre> <p>Your HTTPS URL used this format: <code>https://codeberg.org/<user>/<repo>.git</code> The SSH URL uses this format: <code>git@codeberg.org:<user>/<repo>.git</code> (optionally with <code>ssh://</code> at the beginning like this: <code>ssh://git@codeberg.org:<user>/<repo>.git</code>).</p> <p>Alternatively, you can find the SSH URL by going to your repository page on Codeberg (for example, going to <code>https://codeberg.org/knut/foobar</code>), clicking on SSH in the top right corner and copying the URL.</p> </li> <li> <p>Verify that your change was successful:</p> <pre><code>git remote -v </code></pre> <p>The output should look like this:</p> <pre><code>origin ssh://git@codeberg.org:knut/foobar.git (fetch) origin ssh://git@codeberg.org:knut/foobar.git (push) </code></pre> </li> </ol> <blockquote class="alert"> <p><strong>Attribution</strong><br> This guide is derived from <a href="https://docs.github.com">GitHub Docs</a>, used under CC-BY 4.0.</p> </blockquote> <hr class="mb-20"> <div class="card" data-pagefind-ignore="all"> <p>Hey there! 馃憢 Thank you for reading this article!</p> <p> Is there something missing, or do you have an idea on how to improve the documentation? Do you want to write your own article? </p> <p> You're invited to contribute to the Codeberg Documentation at <a href="https://codeberg.org/Codeberg/Documentation">its source code repository</a>, for example, by <a href="/collaborating/pull-requests-and-git-flow">adding a pull request</a> or joining in on the discussion in <a href="https://codeberg.org/Codeberg/Documentation/issues">the issue tracker</a>. </p> <p> For an introduction on contributing to Codeberg Documentation, please have a look at <a href="https://docs.codeberg.org/improving-codeberg/docs-contributor-faq">the Contributor FAQ</a>. </p> </div> <div class="text-right font-size-16" data-pagefind-ignore="all"> <p>© Codeberg Docs Contributors. See <a href="#modal-1" role="button">LICENSE</a></p> </div> </div> <nav class="col-xl-3 position-relative d-none d-xl-block" id="toc-side" data-pagefind-ignore="all"> <div class="position-fixed mr-20"> <span>On this page</span> <div id="toc" class="overflow-y-auto" style="max-height: 43.75rem;"> <ol><li><a class="sidebar-link" href="#generating-an-ssh-key-pair">Generating an SSH key pair</a><ol><li><a class="sidebar-link" href="#fido2-with-openssh">FIDO2 with OpenSSH</a></li></ol></li> <li><a class="sidebar-link" href="#add-the-ssh-key-to-codeberg">Add the SSH key to Codeberg</a></li> <li><a class="sidebar-link" href="#test-the-ssh-connection">Test the SSH connection</a></li> <li><a class="sidebar-link" href="#verifying-your-ssh-key">Verifying your SSH Key</a></li> <li><a class="sidebar-link" href="#telling-git-about-your-ssh-key">Telling Git about your SSH key</a></li> <li><a class="sidebar-link" href="#avoid-re-typing-the-passphrase">Avoid re-typing the passphrase</a></li> <li><a class="sidebar-link" href="#changing-your-repository's-transport-from-https-to-ssh">Changing your repository's transport from HTTPS to SSH</a></li></ol> </div> </div> </nav> </div> </div> </div> </div> </body> </html>