`

ssh password and passphrase

阅读更多
1、ssh-keygen -t rsa
   采用默认路径,输入passphrase。
2、scp /root/.ssh/id_rsa.pub remote:/root/.ssh/authorized_keys
   需要输入root在远程机器的帐号密码
3、eval `ssh-agent`
4、ssh-add
   输入之前输入的passphrase。


说明
1,2两步是用来生成rsa公钥/私钥对的。
第一步产生了密钥对,id_rsa文件中是私钥,id_rsa.pub是公钥,也可以产生dsa方式的密钥对
第二步将公钥附加到远程主机的/root/.ssh/authorized_keys文件后面。因为之前该文件是空的,所以直接scp;如果非空,则首先scp到临时文件,然后再cat。

3,4两步用来预制Passphrase.
第三步运行ssh-agent的输出(这是eval 反引号的功能),会设置两个环境变量SSH_AUTH_SOCK和SSH_AGENT_PID,这样程序可以访问后台的ssh-agent程序
第四步设置passphrase。

完成这四步,以后ssh或者scp就不会提示输入passphrase。
如果只完成1,2两步,则会提示输入passphrase。
如果都不作,则提示输入在远程机器的帐号密码。

passphrase是用来对密钥对的私钥进行加密的,不会在网络上传播。

缺点:3,4必需每次登录都执行。因为3设置环境变量,不同的登录是不同的。但对于shell,可以放在.bash_profile中执行,对于cron脚本,也可以在脚本中设置执行;4更是致命的,因为它是交互的,无法自定执行。

解决:只好设置passphrase为空,这样3,4两步也就省掉了。

附:

ssh-agent 程序如同一个看门人,它根据需要安全地提供对安全密钥的访问。ssh-agent 启动后,它就会在后台运行,并且可以由 ssh 和 scp 程序等其他 OpenSSH 应用程序所使用。这就使得 ssh 程序可以请求一个已经解密了的密钥,而不是在每次需要时向您询问私钥的安全口令
分享到:
评论

相关推荐

    git关于ssh的学习

    利用git时需要配置ssh,这里的文档清晰的描述了

    How to use SFTP

    The client's private key is loaded via SSHFTPClient's setAuthentication method before calling connect, supplying the full path of the private key file, the SSH username and the passphrase of the ...

    ssh-action:用于执行远程ssh命令的GitHub操作

    passphrase -密码短语通常用于加密私钥 sync如果有多个主机,则同步执行,默认为false timeout -ssh到远程主机的超时,默认为30s command_timeout -ssh命令的超时,默认为10m key -ssh私钥的内容。 〜/ .ssh / id...

    expect中为send语句上加变量的代码

    代码如下:#!...” {send “yes\r” }sleep 1expect “Enter passphrase for key*”send “$password\r”for {set snum 0} {$snum <= 6} {incr snum} {expect “*#”send “ls -l /opt/backup/fivetre

    hemingway:用于检查静态 ruby​​ 代码分析器 Rubocop 结果的 Web 应用程序

    = ENV["SECRET_KEY_BASE"] %> github_key: YOUR_GITHUB_KEY github_secret: YOUR_GITHUB_SECRET ssh_passphrase: YOUR_SSH_PASSPHRASE ssh_private_key: YOUR_SSH_PRIVATE_KEY_PASSWORD秘密描述github_key 您的 ...

    gitosis git服务器架设软件

    Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/john/.ssh/id_rsa. Your public key has been saved in /home/john/.ssh/id_rsa.pub....

    aws-ha-webapp-terraform

    就我而言,我使用ssh-keygen命令,如下所示: ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/home/qaizar/.ssh/id_rsa): ./keys/terraformEnter passphrase ...

    oracle asm rac

    BAD PASSWORD: it is based on a dictionary word Retype new UNIX password: passwd: all authentication tokens updated successfully. 创建grid目录结构 mkdir -p /u01/app/oraInventory chown -R grid:oinstall...

    herd:用于管理小型服务器集群的库

    放牧Herd 是一个正在进行的、易于使用的框架...入门pip 安装羊群创建基本配置文件: [ssh] path = "/path/to/rsaprivatekey" password = 'rsa_key_passphrase' [providers.digitalocean] token = "MY_PRIVATE_TOKEN"

    计算机网络第六版答案

    For example, she can easily change the phrase “Alice, I owe you $1000” to “Alice, I owe you $10,000”. Furthermore, Trudy can even drop the packets that are being sent by Bob to Alice (and vise-...

Global site tag (gtag.js) - Google Analytics