Générer votre paire de clés SSH
ssh-keygen -o -t rsa -b 4096 -C "germain@pop-os"
Pour voir vos clés :
- Publique :
~/.ssh/id_rsa.pub
- Privée :
~/.ssh/id_rsa
Installer l’extension vscode-sftp
À installer directement depuis VS Code :
Ou à télécharger sur https://github.com/liximomo/vscode-sftp
Configurer le remote
Avec la palette VSC, lancer SFTP config
Exemple de fichier :
{
"name": "remote",
"host": "ftp.remote.com",
"protocol": "sftp",
"port": 22,
"username": "username",
"privateKeyPath": "~/.ssh/id_rsa",
"remotePath": "/web",
"uploadOnSave": false
}
Ajouter votre clé SSH au remote
germain@pop-os:~/Téléchargements$ ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote.com /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/germain/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys user@remote.com's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'user@remote.com'" and check to make sure that only the key(s) you wanted were added.
germain@pop-os:~/Téléchargements$ ssh user@remote.com
Welcome to Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-124-generic x86_64)
Last login: Thu Jun 10 15:59:39 2021 from 212.83.190.169 user@remote.com:~$ exit Connection to remote.com closed.
Upload / download de fichiers / dossiers
Erreur « No such file »
Cette erreur est survenue depuis une MàJ estivale de VSC.
Do a search inside ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js
for options.emitClose = false;
Add options.autoDestroy = false;
after both instances.