SSH免密码登录
2010-12-17 17:36
274 查看
一、原理
使用公钥登录服务器,而非密码
二、使用命令
ssh-keygen:生成密钥对(一路回车),执行结果如下:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/test/.ssh/id_rsa):
Created directory '/home/test/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/test/.ssh/id_rsa.
Your public key has been saved in /home/test/.ssh/id_rsa.pub.
The key fingerprint is:
c4:d0:12:79:bb:4b:f3:b9:2a:6b:9f:a0:8c:b7:35:40 test@localhost
将会在默认目录(当前用户家目录的.ssh目录)生成密钥对(公钥:id_rsa.pub,私钥:id_rsa)
ssh-copy-id -i ~/.ssh/id_rsa test@192.168.1.2 :将公钥复制到远程服务器,写入授权列表文件
The authenticity of host '192.168.1.2 (192.168.1.2)' can't be established.
RSA key fingerprint is b3:01:50:26:e0:3f:33:dc:63:a2:7b:3e:46:03:46:bd.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.2' (RSA) to the list of known hosts.
test@192.168.1.2's password:
Now try logging into the machine, with "ssh '192.168.1.2'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
第一次需要输入密码,密码认证成功后,将会把本地服务器的id_rsa.pub内容添加到远程服务器的authorized_keys文件中。
三、应用
01:使用ssh命令登录到远程服务器执行指定的命令,远程服务器的端口为1234,如果为默认的22,则无需指定。
02:使用scp命令拷贝文件到远程服务器的指定目录,远程服务器的端口为1234,如果为默认的22,则无需指定。
使用公钥登录服务器,而非密码
二、使用命令
ssh-keygen:生成密钥对(一路回车),执行结果如下:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/test/.ssh/id_rsa):
Created directory '/home/test/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/test/.ssh/id_rsa.
Your public key has been saved in /home/test/.ssh/id_rsa.pub.
The key fingerprint is:
c4:d0:12:79:bb:4b:f3:b9:2a:6b:9f:a0:8c:b7:35:40 test@localhost
将会在默认目录(当前用户家目录的.ssh目录)生成密钥对(公钥:id_rsa.pub,私钥:id_rsa)
ssh-copy-id -i ~/.ssh/id_rsa test@192.168.1.2 :将公钥复制到远程服务器,写入授权列表文件
The authenticity of host '192.168.1.2 (192.168.1.2)' can't be established.
RSA key fingerprint is b3:01:50:26:e0:3f:33:dc:63:a2:7b:3e:46:03:46:bd.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.2' (RSA) to the list of known hosts.
test@192.168.1.2's password:
Now try logging into the machine, with "ssh '192.168.1.2'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
第一次需要输入密码,密码认证成功后,将会把本地服务器的id_rsa.pub内容添加到远程服务器的authorized_keys文件中。
三、应用
ssh -i ~/.ssh/id_rsa -p 1234 test@192.168.1.2 "ls -al" scp -i ~/.ssh/id_rsa -P 1234 uploadFile test@192.168.1.2:/home/test/dir
01:使用ssh命令登录到远程服务器执行指定的命令,远程服务器的端口为1234,如果为默认的22,则无需指定。
02:使用scp命令拷贝文件到远程服务器的指定目录,远程服务器的端口为1234,如果为默认的22,则无需指定。
相关文章推荐
- 使用ssh-keygen设置ssh无密码登录
- 【转】服务器添加新用户用ssh-key 登录,并禁用root用户 密码登录
- SSH基本原理和免密码登录
- centos7中实现SSH免密码登录
- Linux系统 配置ssh无密码登录
- ssh免密码登录
- linux中ssh使用rsa免密码登录和下载文件的方法
- ssh 免密码登录
- Linux下ssh免密码登录配置(20160309)
- ssh 免密码登录
- SSH免密码登录
- 使用systemtap抓取ssh登录的用户名和密码
- 如何用一次性密码通过 SSH 安全登录 Linux
- OpenWRT新建普通用户+权限设置+免密码登录(ssh公钥验证)
- centos ssh免密码秘钥登录
- ssh-keygen+ssh-copy-id 在linux下实现ssh无密码登录访问
- 使用ssh公钥实现ssh免密码登录
- ssh免密码登录设置
- ssh 免密码登录
- CentOS 6.9 SSH配置用户免密码登录