From the course: Learning Static Site Building with Jekyll

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Connect to the server

Connect to the server

From the course: Learning Static Site Building with Jekyll

Start my 1-month free trial

Connect to the server

- [Instructor] Let's create the deploy.js script. I'll do New File, call it deploy.js, and we'll start writing the code that we need. I'll start by doing const sftpclient equals require ssh2-sftp-client, which is one of the packages we grabbed via npm. I'll also do next sftp equals new SftpClient. I'm going to declare a variable called itemsToUpload. We'll come back to this in a second. But first I want to have the SFTP client connect to the server. I'll do sftp.connect and pass it some connection information. We need to specify a host, and I'm going to not hardcode the host, but I'm going to do process.env.FTP_DEPLOY_HOST. That'll pull a value from environment variables, and I'll show you how to hook that up a little bit later. I'm going to do the same thing for port, FTP_DEPLOY_PORT, and for username and password, as well. So the password comes from process.env like the other ones, FTP_DEPLOY_PASSWORD. Storing connection information, especially passwords, in environment variables is…

Contents