arthurzwl avatar

ssh 使用

arthurzwl

Published: 20 Dec 2017 › Updated: 20 Dec 2017ssh 使用

ssh 使用

生成本地密钥

ssh-keygen -t rsa
接下来会询问密钥保存路径,即~/.ssh,如果没有特殊需要默认即可。还会询问你是否为密钥创建口令, 如果你对安全性要求不是特别高, 可以直接回车, 设为空。

配置别名和账号

编辑 ~/.ssh/config,增加如下内容

Host arthurzwl
HostName arthurzwl.com
User username
Host是别名,HostName是域名或IP,User则是登陆的用户名

让远程主机记住你

将本地的公钥(前面生成的id_rsa.pub)拷贝到远程主机。

ssh-copy-id arthurzwl
连接重用

在~/.ssh/config中加上

Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p
认证成功后会创建socket文件master-username@arthurzwl.com:22=

检查当前是否已经创建Master连接

ssh arthurzwl.com -O check
发送断开当前Master连接的请求

ssh arthurzwl.com -O exit

Leave ssh 使用 to:

Written by

Read more #ssh posts


Best Posts From arthurzwl

We have not curated any of arthurzwl's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From arthurzwl