简单五步完成ssh无密码登录,含动图

本博客翻译自bash

www.tecmint.com/ssh-passwor…服务器

ssh远程登录服务器,须要密码验证,频繁输入实在是麻烦。创建SSH Password-less(无密码登录)就能够很方便的登录。 假定咱们有两台机器本地与远程less

本地: SSH Client : 192.168.0.12dom

远程: SSH Remote Host : 192.168.0.11ssh

Step 1: 本地创建 SSH-Kegen Keys (192.168.0.12)

打开terminal, 输入以下命令:ide

ssh-keygen -t rsaui

效果以下spa

[tecmint@tecmint.com ~]$ ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/home/tecmint/.ssh/id_rsa): [Press enter key]
Created directory '/home/tecmint/.ssh'.
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Press enter key]
Your identification has been saved in /home/tecmint/.ssh/id_rsa.
Your public key has been saved in /home/tecmint/.ssh/id_rsa.pub.
The key fingerprint is:
5f:ad:40:00:8a:d1:9b:99:b3:b0:f8:08:99:c3:ed:d3 tecmint@tecmint.com
The key's randomart image is: +--[ RSA 2048]----+ | ..oooE.++| | o. o.o | | .. . | | o . . o| | S . . + | | . . . o| | . o o ..| | + + | | +. | +-----------------+ 复制代码

过程动图翻译

Step 2 在远程服务器创建.ssh 文件夹 – 192.168.0.11

接着在terminal输入以下命令, 从本地 192.168.0.12 链接远程服务器 192.168.0.11 此例中使用sheena做为用户名,并将.ssh创建在其名下3d

ssh sheena@192.168.0.11 mkdir -p .ssh

效果以下

[tecmint@tecmint ~]$ ssh sheena@192.168.0.11 mkdir -p .ssh

The authenticity of host '192.168.0.11 (192.168.0.11)' can't be established. RSA key fingerprint is 45:0e:28:11:d6:81:62:16:04:3f:db:38:02:la:22:4e. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.0.11' (ECDSA) to the list of known hosts. sheena@192.168.0.11's password: [Enter Your Password Here]
复制代码

过程动图

Step 3: 上传本地的公钥至远程服务器 – 192.168.0.11

使用ssh从本地上传本地的公钥(id_rsa.pub) 上传到服务器192.168.0.11 在用户sheena的.ssh文件夹下, 并命名为authorized_keys

命令以下:

cat .ssh/id_rsa.pub | ssh sheena@192.168.0.11 'cat >> .ssh/authorized_keys'

效果以下

[tecmint@tecmint ~]$ cat .ssh/id_rsa.pub | ssh sheena@192.168.0.11 'cat >> .ssh/authorized_keys'

sheena@192.168.1.2's password: [Enter Your Password Here] 复制代码

过程动图

Step 4: 在远程服务器添加权限,使其成为可执行文件

命令以下

ssh sheena@192.168.0.11 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

效果以下

[tecmint@tecmint ~]$ ssh sheena@192.168.0.11 "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

sheena@192.168.0.11's password: [Enter Your Password Here] 复制代码

过程动图

Step 5: 大功告成

尝试输入: [tecmint@tecmint ~]$ ssh sheena@192.168.0.11

过程动图

相关文章
相关标签/搜索