赞
踩
一、使用密钥登陆远程服务器
1. 首先在本地机器生成密钥对:
可以先查看本地ssh文件下的所有密钥文件:
ls -al ~/.ssh
使用下面命令即可生成密钥对(公钥id_rsa.pub/私钥 id_rsa)
ssh-keygen
具体运行结果如下图所示:
- Generating public/private rsa key pair.
- Enter file in which to save the key (/Users/****/.ssh/id_rsa):
- Enter passphrase (empty for no passphrase):
- Enter same passphrase again:
- Your identification has been saved in /Users/****/.ssh/id_rsa.
- Your public key has been saved in /Users/****/.ssh/id_rsa.pub.
- The key fingerprint is: ********
2. 修改vscode的远程登陆配置文件config
,配置登录用的私钥地址
(1)在控制面板中(快捷键shift+command+p)输入ssh config,选择本地ssh配置文件名称
一般在用户家目录的.ssh文件夹下/Users/**(user_name)/.ssh/config
(2)配置登录用的私钥地址
- Host host_name
- HostName xxx.xx.xx.xx(ip_address)
- User user_name
- port 22
- IdentityFile /Users/****/.ssh/id_rsa
3. 将公钥内容写入到远程服务器的ssh认证文件中~/.ssh/authorized_keys
ssh-copy-id user_name@ip_address
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。