补充免密访问方法,修正 Markdown 语法错误。
Signed-off-by: ithink.chan <chenyang@autoai.com>
This commit is contained in:
parent
311fb99f35
commit
62161a1626
|
@ -38,7 +38,7 @@ StrictModes yes
|
|||
|
||||
RSAAuthentication yes
|
||||
PubkeyAuthentication yes
|
||||
#AuthorizedKeysFile %h/.ssh/authorized_keys
|
||||
#AuthorizedKeysFile %h/.ssh/authorized_keys
|
||||
|
||||
# Don't read the user's ~/.rhosts and ~/.shosts files
|
||||
IgnoreRhosts yes
|
||||
|
@ -100,25 +100,52 @@ UsePAM yes
|
|||
|
||||
之后在目标机上
|
||||
|
||||
# 开机自运行
|
||||
systemctrl enable sshd.service
|
||||
# 启动 sshd 服务
|
||||
systemctrl start sshd.service
|
||||
# 查看 sshd 服务状态
|
||||
systemctrl status sshd.service
|
||||
```sh
|
||||
# 开机自运行
|
||||
systemctrl enable sshd.service
|
||||
# 启动 sshd 服务
|
||||
systemctrl start sshd.service
|
||||
# 查看 sshd 服务状态
|
||||
systemctrl status sshd.service
|
||||
```
|
||||
|
||||
## SSH 登陆
|
||||
|
||||
在开发机上
|
||||
|
||||
ssh <usrname>@<IP>
|
||||
```sh
|
||||
ssh <User Name>@<IP>
|
||||
```
|
||||
|
||||
## SCP 上传和下载
|
||||
|
||||
SCP 上传
|
||||
|
||||
scp <Local Path or File> <usrname>@<IP>:<Path or File>
|
||||
```sh
|
||||
scp <Local Path or File> <User Name>@<IP>:<Path or File>
|
||||
```
|
||||
|
||||
SCP 下载
|
||||
|
||||
scp <usrname>@<IP>:<Path or File> <Local Path or File>
|
||||
```sh
|
||||
scp <User Name>@<IP>:<Path or File> <Local Path or File>
|
||||
```
|
||||
|
||||
## 免密访问
|
||||
|
||||
ssh 登陆或 scp 的时候每次都输入密码很麻烦,如果用于访问 SSH 服务器的客户端值得信任的话可以授权该主机用户免密登陆。做法是先在客户端生成密钥对,如果已有密钥对可跳过本步骤:
|
||||
|
||||
```sh
|
||||
ssh-keygen
|
||||
```
|
||||
|
||||
之后在客户端使用:
|
||||
|
||||
```sh
|
||||
ssh-copy-id <User Name>@<IP>
|
||||
# 后续按照提示进行操作即可
|
||||
```
|
||||
|
||||
命令将客户端的 ssh public key 提供给服务器,之后该客户端的授权账号(拥有该密钥对的账号)就可以免密访问服务器了。
|
||||
|
||||
在服务器的 \<User Home\>/.ssh/authorized_keys 文件中可以看到已授权客户端公钥,删除公钥可取消对应客户端账户的免密访问权限。
|
||||
|
|
Loading…
Reference in New Issue