1. Archlinux开启ssh服务
-
安装openssh
pacman -Sy openssh -
修改
/etc/ssh/sshd_config
PermitRootLogin yes PubkeyAuthentication yes PasswordAuthentication yes
-
自启动
systemctl enable sshd
2. VSCode配置Remote-ssh
-
选择设置 Remote.SSH:Show Login Terminal
-
配置ssh
# Read more about SSH config files: https://linux.die.net/man/5/ssh_config Host Archlinux HostName 192.168.76.151 User root Port 22 IdentityFile "C:\Users\XSS\.ssh\id_rsa"
3. 设置公钥
-
生成公钥
- 安装Git
- 使用Git Bash生成密钥
ssh-keygen #生成的私钥和公钥存储在`C:\Users\PC\.ssh`,分别为`id_rsa`和`id_rsa.pub`
-
安装公钥
# Archlinux cat id_rsa.pub >> authorized_keys chmod 600 authorized_keys
-
设置公钥访问
- 使用Git Bash
ssh-copy-id -i .ssh/id_rsa.pub username@hostname
- 使用Git Bash
4. 使用
-
远程连接
-
新建终端
-
打开远程目录作为工作区