While we recommend HTTPS because it is generally easier to set up, you can also use SSH keys to establish a secure connection between your computer and GitHub. The steps below will walk you through generating an SSH key and then adding the public key to your GitHub account.
Step 1: Check for SSH keys
First, we need to check for existing ssh keys on your computer. Open up Terminal and run:
cd ~/.ssh ls # Lists the files in your .ssh directory
Check the directory listing to see if you have a file named either id_rsa.pub
or id_dsa.pub
. If you don't have either of those files go to step 2. Otherwise, you already have an existing keypair, and you can skip to step 3.
Step 2: Generate a new SSH key
To generate a new SSH key, enter the code below. We want the default settings so when asked to enter a file in which to save the key, just press enter.
ssh-keygen -t rsa -C "your_email@example.com" # 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): ssh-add id_rsa
Now you need to enter a passphrase.
# 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 your_email@example.com
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
相关推荐
将公钥上传到远程服务器的`~/.ssh2/authorized_keys`文件中。 ##### 2. 使用SSH进行连接 连接远程服务器时,无需输入密码,而是通过密钥对进行身份验证。 ```bash local# ssh remote.pku.edu.cn Passphrase for ...
- **权限管理**:确保`.ssh`目录及`authorized_keys`文件的权限设置正确,避免非授权用户访问。 - **定期审核**:定期检查`authorized_keys`文件中的公钥列表,移除不再使用的公钥,确保系统的安全性。 #### 结论 ...
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys ``` 3. **测试免密登录**:在本地机上尝试使用新的私钥进行免密登录。 - 新建一个SSH会话,输入服务器的IP地址、用户名...
使用`ssh-copy-id`命令将本地主机的公钥复制到远程主机的`~/.ssh/authorized_keys`文件中,以允许无密码登录。例如,如果远程主机IP为192.168.0.178,运行: ``` [root@test ~]# ssh-copy-id -i ~/.ssh/id_rsa....
使用`scp`命令将公钥`id_rsa.pub`复制到远程主机的对应用户目录下的`.ssh/authorized_keys`文件。如果远程主机的`.ssh`目录或`authorized_keys`文件不存在,需要先创建它们。 ```bash [azuo1228@test-server ....
用户在本地主机上生成一对RSA密钥(公钥与私钥),然后将公钥复制到远程服务器的`~/.ssh/authorized_keys`文件中。当用户尝试连接远程服务器时,服务器会使用已存储的公钥来验证用户的私钥,如果匹配成功,则允许...
https://help.github.com/articles/generating-ssh-keys/ 3.初始化用户名,邮箱 $ git config –global user.name “defnngj”//给自己起个用户名 $ git config –global user.email “defnngj@gmail.com”//填写自己...
我们先使用usera 登录 serverA 服务器 [root@serverA ~]# su - usera ...[usera@serverA ~]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/usera/.s
[root@node1 ~]# vim /root/.ssh/authorized_keys ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqx16gwciSttzoc/rgtKrE45kLl7vTpmvc5qDvzB6LWEm5jp9b/SdUy0qBVx5yZ5/nBmkqUbDZQBsG//Qi4rw8w7kIc14IOxn0U4s0bG/3...
- 在服务器B的`.ssh`目录下创建或修改`authorized_keys`文件,将`id_rsa.pub`的内容追加进去。 - 如果有多个服务器需要相互之间实现无密码访问,则将各服务器的`id_rsa.pub`内容追加到`authorized_keys`文件中即可...
这里使用`ssh-copy-id`命令将当前用户的公钥复制到目标主机的`~/.ssh/authorized_keys`文件中,从而实现从当前主机到目标主机的免密登录功能。需要注意的是,`-p 22`参数指定了SSH服务端口为22,默认情况下可以省略...
就我而言,我使用ssh-keygen命令,如下所示: ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/home/qaizar/.ssh/id_rsa): ./keys/terraformEnter passphrase ...
一、安装前准备 磁盘规划 使用iscsi共享磁盘做成raw设备 Vote_OCR /dev/sdb1 /dev/raw/raw1 Vote_OCR /dev/sdb2 /dev/raw/raw2 Vote_OCR /dev/sdb3 /dev/raw/raw3 Vote_OCR /dev/sdb5 /dev/raw/raw4 ...
Generating RSA Keys... [OK] Router(Config)#</P><P>2、 TCP SYN的防范。如: A: 通过访问列表防范。 Router(Config)# no access-list 106 Router(Config)# access-list 106 permit tcp any 192.168.0.0 0.0.0....
Building a Dict from a List of Alternating Keys and Values Recipe 4.13. Extracting a Subset of a Dictionary Recipe 4.14. Inverting a Dictionary Recipe 4.15. Associating Multiple Values with ...
It adds header to each chunk, thereby generating multiple packets from the file. The header in each packet includes the IP address of the destination (end system B). The packet switch uses the ...