-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# SSH设置远程电脑免密连接脚本 | ||
|
||
|
||
## 脚本 | ||
```bash | ||
#将本机的公钥添加到远程服务器的authorized_keys中 | ||
#实现免密码登陆 | ||
#检测本地是否有公钥否则生成密钥对 | ||
IP='x.x.x.x' | ||
USER='xrisk' | ||
if [ -f ~/.ssh/id_rsa.pub ]; then | ||
echo "公钥已存在" | ||
else | ||
echo "公钥不存在,开始生成" | ||
ssh-keygen -t rsa -f ~/.ssh/id_rsa -P "" | ||
fi | ||
ssh-copy-id -i ~/.ssh/id_rsa.pub ${USER}@${IP} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters