Connect to Synology NAS via SSH using VSCode

Connect to the NAS using PuTTy

A bit silly, but first you need to connect via SSH using PuTTy

Edit TCP Forwarding

Navigate to etc/ssh/ and edit the file sshd_config using vim (vim sshd_config).

Press i to enter insert mode, then go down through the file until you find AllowTcpForwarding no. Change it to AllowTcpForwarding yes and then press Esc to get out of insert mode. Type :wq to save and quit.

Edit user watches

VSCode will also complain about not being able to watch so many files when you connect to the NAS via SSH. To address this, sill using PuTTy, type cat /proc/sys/fs/inotify/max_user_watches. This should print 8192. We need to change this value to be much higher. To do this, type

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Restart SSH

Close PuTTy, navigate to your Synology dashboard, go in Control Panel > Terminal & SMNP > Terminal, disable SSH and press Apply. Then enable it again, and press Apply.

Connect VSCode

Get SSH Remote

From the Extension Marketplace get Remote - SSH. In the settings, you will find Remote.SSH Config File which requires a path. Give it a path to a cofig file you create, looking something like this

Host 192.168.X.XXX
  HostName MyNAS
  User username
  Port portNumber

Connect

If everything was set up correctly, from Remote Connections you should be able to start a connection with your NAS without issues.