using Renci.SshNet;
using System;
class SftpExample
{
static void Main()
{
string host = "SFTP_HOST";
string username = "USERNAME";
// ppkファイルはpemに変換しておく
string privateKeyFilePath = "path/to/your/privatekey.pem";
string privateKeyPassphrase = "PRIVATE_KEY_PASSPHRASE"; // パスフレーズがある場合
using (var client = new SftpClient(host, username, new PrivateKeyFile(privateKeyFilePath, privateKeyPassphrase)))
{
client.Connect();
// ここでSFTP操作を行います
client.Disconnect();
}
}
}
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme