`
stephen830
  • 浏览: 2964553 次
  • 性别: 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免密登录时报错:/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) ...

    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

    Linux配置远程SSH无密码登录

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

    【大数据】虚拟机免密登录.pdf

    【⼤数据】虚拟机免密登录 ⼀.ssh-keygen -t rsa 输⼊⽂件名xxx,此⽂件名下⼀步要⽤ ⼆.ssh-copy-id -i xxx.pub hadoop@hadoop02 将此密钥⽂件拷贝⾄其他机器 三、hadoop02授权 chmod g-w /home/hadoop chmod 700 /...

    tools-ssh-copy

    [VERT] Estabelecendorelaçãodeconfiança 热那亚人托多斯·奥·科曼多斯·德沃姆 要求前 吉特 ...cd vert_suporte/ Python ...Enter file in which to save the key (/root/.ssh/id_rsa): <ENTER

    052801简单的网络客户端命令1

    1、ssh-keygen -t rsa 2、ssh-copy-id -i /root/.ssh/id_rsa.pub USERNAME@host 这样原来的

    hadoop安装

    [hadoop@a1 ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub a3 [hadoop@a2 ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub a1 [hadoop@a2 ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub a2 [hadoop@a2 ~]...

    budgie:通过 ssh 远程控制服务器

    venv/bin/activate # optional pip install budgie您需要为远程主机配置无密码 SSH: ssh-keygen -q -t rsa -N 'your_password_here' -f ~/.ssh/id_rsa ssh-copy-id localhost # Repeat this for each host eval &#...

    ansible-30-min

    .ssh / demo_id_rsa更新主机: vim主机更新SSH密钥文件路径: vim主机验证并获取有关您的Ansible库存的信息ansible-inventory -i主机--list部署公钥托管ssh-copy-id -i〜/ .ssh / demo_id_rsa.pub demouser@138.91....

    ubuntu16.04服务器配置ssh免密码登录

    ssh-copy-id root@123.45.56.78(你的服务器ip), 或这使用 cat ~/.ssh/id_rsa.pub | ssh user@123.45.56.78 mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys 即可将,你的客户端key传到服务器的~/.ssh/...

    毕业设计-基于树莓派的寝室小监控系统(Python).zip

    ssh-copy-id username@server_ip 新建autossh自启动脚本, chmod a+x autossh 并运行, 脚本的内容: #!/bin/bash /bin/su -c '/usr/bin/autossh -M 1234 -NR 19999:localhost:22 buhuipao@server_ip -p your_port' -...

    Linux—设置虚拟机之间免密登录—超详细—技术帖

    Linux—设置虚拟机之间免密登录,适合集群之间,方便文件传输。 设置免密登录 很多帖子发的免密登录我不想吐槽,实力带躺,好好看下面五杀操作 为什么设置免密 从一台虚拟机上登录到另一台需要密码,两...ssh-copy-id h

    MySQL高可用架构MHA

    ssh-copy-id 192.168.100.10(20.30.102) 2.上传安装包,解压编译安装 配置yum仓库 vim /etc/yum.repos.d/mhapath.repo ##进入yum仓库,插入以下 [mha] name=mhapath baseurl=file:///root/mhapath enabled=1 ...

    serverSetup:设置ubuntu服务器的清单

    如果本地计算机上有ssh-copy-id,请使用它。 local$ ssh-copy-id username@serverName.local否则,请手动进行。 local$ cat local$ ssh username@serverName.localserver-ssh-shell$ cd ~/server-ssh-shell$ mkdir ...

    install-hadoop:Apache Hadoop 安装自动化

    Apache Hadoop 安装 ... $ ssh-copy-id -i ~/.ssh/id_rsa.pub localhost $ ssh localhost $ exit install OpenJdk 1.7 sudo apt-get install openjdk-7-jdk Set JAVA_HOME in .bashrc export JAVA

    remarkable_mouse:将您的 reMarkable 用作绘图板

    非凡鼠标 将您的 reMarkable 用作绘图板。 特别感谢和的启发。 快速开始 在通过 USB 插入平板电脑的主机上: pip install remarkable-mouse remouse 默认情况下, 10.11.99.1...ssh-copy-id -i ~ /.ssh/remarkable

    docker-library:docker-library

    ssh - copy-id - i ~ / .ssh / id_rsa.pub root @192 .168.1.3 # Install pip for Ubuntu sudo apt install python - pip # Install dependencies from ``requirements.txt` sudo pip install - r requirements.txt ...

    winsows通过ssh远程登录linux系统

    第一种1.安装git bash $ ssh 用户名@ ip地址 -p 端口号 例如:$ ssh root@111.44.254.164 -p 20003 ...将电脑ssh公钥添加到服务器:ssky-keygen + ssh-copy-id 无密码登陆远程LINUX主机 有一篇文章

    autossh-tunnel:autossh init.c脚本在启动时创建ssh隧道

    $ssh-copy-id user@remotehost...或者仅使用ssh ... $cat ~/.ssh/id_rsa.pub | ssh user@remotehost "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"现在测试您可以不用密码访问远程服务器$ssh user@remote...

Global site tag (gtag.js) - Google Analytics