Generating SSH Keys [Ubuntu Linux]

Generating SSH Keys

We strongly recommend using an SSH connection when interacting with GitHub. SSH keys are a way to identify trusted computers, without involving passwords. The steps below will walk you through generating an SSH key and then adding the public key to your GitHub account.

Tip: We recommend that you regularly review your SSH keys list and revoke any that haven‘t been used in a while.

Step 1: Check for SSH keys

First, we need to check for existing SSH keys on your computer. Open up your Terminal and type:

cd ~/.ssh
ls -al
# Lists the files in your .ssh directory

Check the directory listing to see if you have files named either id_rsa.pub or id_dsa.pub. If you don‘t have either of those files go to step 2. Otherwise, you can skip to step 3.

Step 2: Generate a new SSH key

To generate a new SSH key, copy and paste the text below, making sure to substitute in your email. The default settings are preferred, so when you‘re asked to "enter a file in which to save the key,"" just press enter to continue.

ssh-keygen -t rsa -C "[email protected]"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/home/you/.ssh/id_rsa):

Next, you‘ll be asked to enter a passphrase.

Tip: We strongly recommend a very good, secure passphrase. For more information, see Working with SSH key passphrases.

# Enter passphrase (empty for no passphrase): [Type a passphrase]
# Enter same passphrase again: [Type passphrase again]

Which should give you something like this:

# Your identification has been saved in /home/you/.ssh/id_rsa.
# Your public key has been saved in /home/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected]

Then add your new key to the ssh-agent:

# start the ssh-agent in the background and be careful `` is not ‘‘
eval `ssh-agent -s`            
# Agent pid 59566
ssh-add ~/.ssh/id_rsa

Step 3: Add your SSH key to GitHub

Run the following code to copy the key to your clipboard.

sudo apt-get install xclip
# Downloads and installs xclip. If you don‘t have `apt-get`, you might need to use another installer (like `yum`)

xclip -sel clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard

Alternatively, using your favorite text editor, you can open the ~/.ssh/id_rsa.pub file and copy the contents of the file manually

Step 4: Test everything out

To make sure everything is working, you‘ll now try SSHing to GitHub. When you do this, you will be asked to authenticate this action using your password, which was the passphrase you created earlier.

Open up your Terminal and type:

ssh -T [email protected]
# Attempts to ssh to github

It‘s possible that you‘ll see this error message:

...
Agent admitted failure to sign using the key.
debug1: No more authentication methods to try.
Permission denied (publickey).

This is a known problem with certain Linux distributions. For a possible resolution, see our help article.

You may see this warning:

# The authenticity of host ‘github.com (207.97.227.239)‘ can‘t be established.
# RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
# Are you sure you want to continue connecting (yes/no)?

Don‘t worry! This is supposed to happen. Verify that the fingerprint in your terminal matches the one we‘ve provided up above, and then type "yes."

# Hi username! You‘ve successfully authenticated, but GitHub does not
# provide shell access.

If that username is yours, you‘ve successfully set up your SSH key! Don‘t worry about the "shell access" thing, you don‘t want that anyway.

More details:  https://help.github.com/articles/generating-ssh-keys

Generating SSH Keys [Ubuntu Linux],布布扣,bubuko.com

时间: 2024-11-25 10:00:58

Generating SSH Keys [Ubuntu Linux]的相关文章

Generating SSH keys

Generating SSH keys MAC WINDOWS LINUX ALL SSH keys are a way to identify trusted computers, without involving passwords. The steps below will walk you through generating an SSH key and adding the public key to your GitHub account. We recommend that y

Generating SSH Keys on windows

two ways here I provide: use openSSH command line on git bash(such as msysgit bash) ls -al ~/.ssh ssh-keygen -t rsa -C "[email protected]" eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_rsa clip < ~/.ssh/id_rsa.pub ssh -T [email protected

Github 配置SSH keys教程

不知道什么原因,CSDN博客保存的时候会丢失图片和格式,请可以戳这里到我有道云笔记分享 今天特地把Github上的教程Github Generating SSH keys翻译成中文(并非全文翻译),因为自己的水平有限,有错误还请指出. SSH key 是为了确认你是项目的管理者或拥有者,然后可以不使用密码使用git.当然使用github的时候要用SSH链接,用https的话就无所谓了.  https可以clone任何人的project,但SSH只能clone属于你的,你必须是这个项目的拥有者.

为github帐号添加SSH keys(Linux和Windows)

文章转自:https://blog.cofface.com/archives/406.html/2 一.Linux增加ssh keys方法: 使用git clone命令从github上同步github上的代码库时,如果使用SSH链接(如我自己的cofface_recovery项目:[email protected]:cofface/cofface_recovery.git),而你的SSH key没有添加到github帐号设置中,系统会报下面的错误:Permission denied (publi

Ubuntu下升级Git以及获取ssh keys的代码

今天开始用的git,记下获取ssh keys 的代码 ? 1 2 3 ssh-keygen -t rsa -C "[email protected]" # Enter file in which to save the key (/home/you/.ssh/id_rsa): ssh-add id_rsa http://my.oschina.net/silentboy/blog/195741?p=1 这里建议直接回车,就在当前目录下创建id_rsa.pub,不然会像我一样,路径搞错,v

[转] windows 上用程序putty使用 ssh自动登录Linux(Ubuntu)

需求: 在Win7电脑上使用putty(一种ssh客户端)连接Ubuntu 工具: puttygen.exe 和 putty.exe 第一步:生成密匙 运行puttygen.exe,选择需要的密匙类型和长度,使用默认的SSH2(RSA),长度设置为1024就可以了. passphrase可以为空,免得登录时还是要输入一次密码. 点击Save private key 按钮保存私匙,例如key.ppk: 复制puttygen public Key 文本框内的内容到剪贴板中. 第二步:上传密匙 用Pu

SSH keys Generate

An SSH key allows you to establish a secure connection between your computer and GitLab. Before generating an SSH key, check if your system already has one by running cat ~/.ssh/id_rsa.pub. If you see a long string starting with ssh-rsa or ssh-dsa, y

git SSH keys

An SSH key allows you to establish a secure connection between your computer and GitLab. Before generating an SSH key in your shell, check if your system already has one by running the following command: Windows Command Line: type %userprofile%\.ssh\

Gitlab的SSH配置(linux和window双版本)

1. 步骤 1.首先现在电脑端安装好git,window端请安装Git for Windows,Linux端请自行网上查询 2.先核对下电脑上是已经有ssh配置 #Git Bash on Windows / GNU/Linux / macOS / PowerShell: cat ~/.ssh/id_rsa.pub 3.若没有,则需要生成ssh的公钥私钥 Git Bash on Windows / GNU/Linux / macOS: #请先切换目录到 ~/.ssh/下 #如果不切换,当保存的文件