SSH免密登录(SSH password free login)

SSH免密登录实现三步:

  • 客户端生成公钥和私钥
  • 上传公钥到服务端
  • SSH免密登录

(1) 客户端生成和公钥和私钥

ssh-keygen

一路回车即可,默认会在~/.ssh/目录下创建公私钥。

客户端是windows平台,则会在 C:\Users\用户名\.ssh\ 目录下生成公私钥

客户端是windows平台,则会在 C:\Users\用户名\.ssh\ 目录下生成公私钥

(2) 上传公钥到服务器

ssh-copy-id -i ~/.ssh/id_rsa.pub 用户名@IP地址(或主机名)

将客户端公钥写入到服务器的~/.ssh/authorized_keys中。

Windows客户端可以通过git bash执行该命令

Windows客户端可以通过git bash执行该命令

(3) SSH免密登录

ssh 用户名@IP地址(或主机名)
————————

SSH password free login is realized in three steps:

  • Client generates public and private keys
  • Upload the public key to the server
  • SSH password free login

(1) Client generated public and private keys

ssh-keygen

Just press enter all the way. By default, it will be in ~ / Create public and private keys under SSH / directory.

If the client is a Windows platform, it will be displayed in C: \ users \ user name \ Generate public and private keys under SSH \ directory

If the client is a Windows platform, it will be displayed in C: \ users \ user name \ Generate public and private keys under SSH \ directory

(2) Upload public key to server

ssh-copy-id -i ~/.ssh/id_rsa.pub 用户名@IP地址(或主机名)

Write the client public key to the ~ /. Of the server ssh/authorized_ Keys.

The Windows client can execute this command through git bash

The Windows client can execute this command through git bash

(3) SSH password free login

ssh 用户名@IP地址(或主机名)