# ssh-copy-id

把本地的ssh公钥文件安装到远程主机对应的账户下

## 补充说明

**ssh-copy-id命令** 可以把本地主机的公钥复制到远程主机的authorized\_keys文件上，ssh-copy-id命令也会给远程主机的用户主目录（home）和`~/.ssh`, 和`~/.ssh/authorized_keys`设置合适的权限。

### 语法

```
ssh-copy-id [-i [identity_file]] [user@]machine
```

### 选项

```
-i：指定公钥文件
```

### 实例

1、把本地的ssh公钥文件安装到远程主机对应的账户下：

```
ssh-copy-id user@server
ssh-copy-id -i ~/.ssh/id_rsa.pub user@server
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hezhiqiang.gitbook.io/linux/ming-ling/ssh-copy-id.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
