如何在不使用密码的情况下进行SSH登录 [英] how to SSH Login Without Password
本文介绍了如何在不使用密码的情况下进行SSH登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在脚本中使用sftp,而无需用户交互(非交互).例如,登录到匿名ftp服务器而不必手动.
To use sftp in a script without user interaction (non-interactive). For example to login to an anonymous ftp server and not have to manually.
推荐答案
在您的计算机上
cd ~/.ssh
ssh-keygen -t dsa
在每次提示时按Enter键
press the enter key at every prompt
Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_dsa.
Your public key has been saved in /home/user/.ssh/id_dsa.pub.
The key fingerprint is:
ad:98:43:13:c9:ea:66:8e:d0:d9:66:59:d8:3a:f7:29
The key's randomart image is:
+--[ DSA 1024]----+
| |
| . . |
| + |
| + . . |
| o = S . |
| . + = + . |
|. o @ = . |
| . B oEo . |
| . . .o |
+-----------------+
您将获得2个文件id_dsa
和id_dsa.pub
使用scp或其他实用程序将文件复制到您的服务器
you will get 2 files id_dsa
and id_dsa.pub
use scp or other utility to copy file to your server
scp ~/.ssh/id_dsa.pub user@host:~/.ssh/
在您的服务器上
将新密钥添加到文件〜/.ssh/authorized_keys.
Add the new key to the file ~/.ssh/authorized_keys.
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
最后更改访问模式;
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
验证访问模式是否适用于〜
Verify that access mode is correct for ~
ls -ld ~
如果没有,您可以使用
chmod 700 ~
更正您的家庭访问权限.
to correct your home access.
注销并再次登录
这篇关于如何在不使用密码的情况下进行SSH登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文