LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1322|回复: 3

SSH命令可不可以指定密码?

[复制链接]
发表于 2011-2-24 22:40:43 | 显示全部楼层 |阅读模式
如题,可不可以指定密码,省的每次要输入一次密码。
发表于 2011-2-25 09:17:14 | 显示全部楼层
指定使用 rsa 密钥认证即可,网上搜一下。
回复 支持 反对

使用道具 举报

发表于 2011-3-4 10:30:04 | 显示全部楼层
First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:
a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A

Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):
a@A:~> ssh b@B mkdir -p .ssh
b@B's password:

Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:
a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password:

From now on you can log into B as b from A as a without password:
a@A:~> ssh b@B hostname
B

A note from one of our readers: Depending on your version of SSH you might also have to do the following changes:
Put the public key in .ssh/authorized_keys2 Change the permissions of .ssh to 700 Change the permissions of .ssh/authorized_keys2 to 640
回复 支持 反对

使用道具 举报

发表于 2011-3-10 05:49:35 | 显示全部楼层
Post by coolwinds;2129834
First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:



Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):


Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:


From now on you can log into B as b from A as a without password:


A note from one of our readers: Depending on your version of SSH you might also have to do the following changes:
Put the public key in .ssh/authorized_keys2 Change the permissions of .ssh to 700 Change the permissions of .ssh/authorized_keys2 to 640


我记得有个命令可以一步到位,作上面的事,忘记了,谁给个提示!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表