`
stephen830
  • 浏览: 2977764 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

ssh-keygen ssh-copy-id 无密码登陆

 
阅读更多

 

ssh-keygen ssh-copy-id 无密码登陆

分类: Ubuntu使用点滴 Android开发 Linux资源 1301人阅读 评论(0) 收藏 举报

进行android开发经常需要登录远程ubuntu server服务器进行编译查看代码等,每次都需要输入密码,很烦人。

使用 ssh-keygen和ssh-copy-id配置一下就可以无需输入密码直接登录服务器了。

ssh-keygen 创建公钥和密钥。
ssh-copy-id 把本地主机的公钥复制到远程主机的authorized_keys文件上。
ssh-copy-id 也会给远程主机的用户主目录(home)和~/.ssh, 和~/.ssh/authorized_keys设置合适的权限 。

 

user@machine:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
43:c6:7d:c4:9c:85:bd:8f:f0:5a:b7:8b:37:e6:e9:12 user@machine
The key's randomart image is:
+--[ RSA 2048]----+
|           o.=.  |
|       . . .= .  |
|        + . .  . |
|       o   .. .  |
|        S    o o |
|         .   E+ o|
|             o...|
|            ...=.|
|             .*=o|
+-----------------+
user@machine:~$ 
user@machine:~$ ls -l .ssh/
total 12
-rw------- 1 user user 1679 Sep  4 16:34 id_rsa
-rw-r--r-- 1 user user  393 Sep  4 16:34 id_rsa.pub
-rw-r--r-- 1 user user  222 Sep  3 13:03 known_hosts
user@machine:~$ ssh-copy-id -i .ssh/id_rsa.pub user@172.16.2.15
user@172.16.2.15's password: 
Now try logging into the machine, with "ssh 'user@172.16.2.15'", and check in:

  ~/.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

user@machine:~$ ssh user@172.16.2.15

 

 如果有端口号的话:

ssh-copy-id -i ~/.ssh/id_rsa.pub  -p 20022 test@192.168.3.2

 

 

分享到:
评论

相关推荐

    ssh-key秘钥无密码登录和批量分发详细笔记文档实战案例

    使用ssh-copy-id命令将公钥分发到远程服务器上,命令语法为`ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.231.129`。 三、无密码登录 在公钥分发完成后,A机器可以无密码登录到B机器和C机器上。使用ssh命令...

    postgres用户下ssh无密码登录

    Postgres用户下SSH无密码登录 SSH(Secure Shell)是一种安全的远程登录协议,用于远程管理Linux系统。 SSH无密码登录是指在两台服务器之间,不需要输入密码便可实现登录的功能。本文将详细介绍Postgres用户下SSH...

    在配置SSH免密登录时报错:/usr/bin/ssh-copy-id: ERROR: failed to open ID file ‘/root/.pub’: 没有那个文件或目录

    [root@hadoop1 sbin]# ssh-copy-id hadoop1 /usr/bin/ssh-copy-id: ERROR: failed to open ID file '/root/.pub': 没有那个文件或目录 (to install the contents of '/root/.pub' anyway, look at the -f option) ...

    linux ssh key

    Linux SSH key 是一种常用的身份验证方式,通过生成公钥和私钥来实现无密码登录远程 Linux 主机。本文将详细介绍如何在 Linux 和 Windows 平台上生成和使用 SSH key。 一、Linux 平台上生成和使用 SSH key 1. 生成...

    ssh(ssh-keygen)配置免输入密码登录远程主机的方法

    在SSH中,`ssh-keygen`是一个用于生成公钥和私钥对的工具,这是实现无密码登录的关键。本篇文章将详细讲解如何通过`ssh-keygen`配置免输入密码登录远程主机。 首先,我们需要在本地主机上生成SSH密钥对。在本地主机...

    SSH无密码登录配置(主要针对Hadoop配置)

    使用`ssh-copy-id`命令将公钥复制到远程服务器,以便服务器知道你是谁,无需输入密码: ```bash ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote_host ``` 这里,`user`是远程主机的用户名,`remote_host`是远程...

    Linux系统ssh无密码登录设置手册.docx

    ssh-copy-id user@remote_host ``` 5.3 配置SSH服务器 编辑远程服务器的`/etc/ssh/sshd_config`文件,确保以下设置: - `PasswordAuthentication no`:禁用密码登录 - `PermitRootLogin no`:禁止root用户通过SSH...

    jenkins中通过Publish Over SSH插件将项目部署到远程机器上的讲解说明

    Publish Over SSH插件使用 在使用Publish Over SSH之前,需要制作SSH私钥。机器间做免密登录配置。...ssh-copy-id 192.168.BB.BBB 验证方式是:在A机器上执行ssh 192.168.BB.BBB,然后执行ifconfig

    ssh-ext.rar

    - **ssh-copy-id**:用于将公钥复制到远程服务器的工具,简化密钥认证的设置。 - **autossh**:自动监控并保持SSH连接的工具,常用于端口转发。 - **OpenSSH**:一个流行的开源SSH实现,提供了多种增强的安全性和...

    SSH Secure Shell绿色版 经典版

    6. **公钥认证**:支持RSA、DSA、ECDSA等公钥算法,用户可以生成一对公钥和私钥,将公钥部署在远程服务器上,私钥留在本地,实现无密码登录。 7. **性能优化**:SSH Secure Shell可能进行了性能优化,使得数据传输...

    gitBash 客户端 ssh 服务器远程登陆

    3. **复制公钥到服务器**:使用`ssh-copy-id`命令将公钥复制到远程服务器的authorized_keys文件中,这样就可以无密码登录。 ```bash ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote_server_ip ``` 4. **测试...

    expect配置单向ssh免密码登录

    使用`ssh-copy-id`命令将公钥复制到远程服务器: ``` ssh-copy-id user@remote_server ``` 这会将公钥添加到远程用户的`~/.ssh/authorized_keys`文件中。 3. **配置expect脚本**: `expect`可以用来自动化SSH...

    sshpass: 用于非交互的 ssh 密码验证

    生成 SSH 密钥对通常使用 `ssh-keygen` 命令,然后使用 `ssh-copy-id` 将公钥复制到远程服务器: ```bash ssh-keygen -t rsa ssh-copy-id -i ~/.ssh/id_rsa.pub user@hostname ``` 完成这一步后,你就可以在本地...

    免密码自动登录SSH(免密登陆SSH)_Shell_下载.zip

    免密码自动登录SSH,也称为SSH无密码登录,是一种通过SSH协议进行远程系统访问时,无需每次输入用户密码的方法。这对于频繁需要在多台服务器之间切换的系统管理员来说,极大地提高了工作效率。本教程将详细解释如何...

    ssh用户登陆代码

    5. **密钥对管理**:将本地的公钥复制到远程服务器的`~/.ssh/authorized_keys`文件中,可以使用`ssh-copy-id`命令: ``` ssh-copy-id -i ~/.ssh/id_rsa.pub user@example.com ``` 6. **SSH代理转发**:SSH代理...

    ssh-程序设计课程专用工具

    可以使用`ssh-copy-id`命令简化此过程。 3. **配置SSH配置文件**:在`~/.ssh/config`文件中,可以定制SSH连接参数,如主机名、端口、用户等,以便快速连接到常用的服务器。 **SSH应用** 1. **远程终端访问**:...

    ssh示例,写的很详细

    使用`ssh-keygen`生成公钥和私钥,然后将公钥复制到远程服务器的`~/.ssh/authorized_keys`文件中,可以实现无密码登录。 `ssh-keygen -t rsa` `ssh-copy-id -i ~/.ssh/id_rsa.pub 用户名@主机地址` 3. **端口...

    Linux系统ssh无密码登录设置手册.pdf

    2. 将本地的公钥复制到远程服务器,可以使用`ssh-copy-id`命令。 3. 配置远程服务器的`~/.ssh/authorized_keys`文件权限,确保只有所有者有读写权限。 4. 测试无密码登录,使用`ssh`命令尝试连接远程服务器。 **4. ...

    Linux配置远程SSH无密码登录

    本文实例为大家分享了jaLinux配置远程SSH无密码登录的方法,供大家参考,具体内容如下 系统:CentOS 6.8 主机1:192.168.0.177 主机2:192.168.0.178 工具介绍: ssh-keygen:创建公钥和密钥 ssh-copy-id:把生成的...

    分发公钥实现无需密码登录远端机器重点简单总结

    在Linux环境中,安全地远程...总的来说,通过分发公钥,你可以实现Linux系统之间的无密码SSH登录,提高效率,同时减少因手动输入密码可能导致的安全风险。这种方式是运维人员和开发者常用的一种自动化安全登录手段。

Global site tag (gtag.js) - Google Analytics