Connect using PuTTY: Connect to AWS Instance using SFTP(PuTTY)

Connect using PuTTY: Connect to AWS Instance using SFTP(PuTTY)

In this post i would like to show how to connect AWS account through SFTP(Secure File Transfer Protocol).PuTTY is a popular SSH, Telnet, and SFTP client for Windows. It is typically used for remote access to server computers over a network using the SSH protocol.Lets see how to connect.

Setup Host Name in PuTTY:

To start using putty we need host name or IP address.We can use Domain name or Public IP Address from AWS as a Host Name.

put-host-name-in-putty

Setup Your PPK File in PuTTY:

After you generating PPK file you have to use this to enable communication securely with AWS having the corresponding public key.To fut PPK file go to the SSH->Auth section and browse to your PPK file.

put-ppk-file-in-putty-auth

Connect to the Server:

Once you setup Host and PPK file then you can connect to the server by clicking open button.After that you will get below screen.

screen-after-connect-putty

Increase Connection Time in PuTTY:

If you want to increase connection time between PuTTY and AWS then go to your putty settings -> Connection and set the value of “Seconds between keepalives” to 30 seconds.After that connection time will be increase.

Thats All,thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this tutorial let us know. We’d love to help!

Get Client key and Client Secret key from AWS:

Login to your aws console. here you can find the Menu “My Billing Dashboard” under profile area.Inside of Access keys (access key ID and secret access key) you need to create new access key and save it to use in future.

Installation and Configuration AWS SDK in codeigniter:

To setup AWS SDK with codeigniter, need to install AWS SDK using composer. You can get it easily installed.Go to your root folder of the codeigniter application and run Below command.

composer require aws/aws-sdk-php

Creating Controller( Email using AWS SES ):

Next, we are going to create a controller file named AwsSesController.php inside application/controllers where we will put all Email configuration and send email function.Please find below the code.

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
use Aws\Common\Aws;
use Aws\Ses\SesClient;
class AwsSesController extends CI_Controller {
publicfunction __construct()
{
parent::__construct();
}
publicfunction sendEmail(){

$params = array(
'credentials'=> array(
'key'=>'CLIENT KEY',
'secret'=>'CLIENT SECRET KEY',
),
'region'=>'us-east-1',
'version'=>'latest'
);
$SesClient = new SesClient($params);

$sender_email = 'hitesh.maity@gmail.com';
$recipient_emails = ['hitesh.maity@gmail.com'];

// Specify a configuration set. If you do not want to use a configuration comment it or delete.
//$configuration_set = 'ConfigSet';

$subject = 'Test Email From Techalltype';
$plaintext_body = 'This email was sent with Amazon SES using the AWS SDK for PHP.' ;
$html_body = '<h1>Test Email From Techalltype</h1>';
$char_set = 'UTF-8';

try {
$result = $SesClient->sendEmail([
'Destination'=> [
'ToAddresses'=> $recipient_emails,
],
'ReplyToAddresses'=> [$sender_email],
'Source'=> $sender_email,
'Message'=> [
'Body'=> [
'Html'=> [
'Charset'=> $char_set,
'Data'=> $html_body,
],
'Text'=> [
'Charset'=> $char_set,
'Data'=> $plaintext_body,
],
],
'Subject'=> [
'Charset'=> $char_set,
'Data'=> $subject,
],
],
// If you aren't using a configuration set, comment or delete the following line
//'ConfigurationSetName' => $configuration_set,
]);
$messageId = $result['MessageId'];
echo("Email sent! Message ID: $messageId"."\n");
} catch (AwsException $e) {
// output error message if fails
echo $e->getMessage();
echo("The email was not sent. Error message: ".$e->getAwsErrorMessage()."\n");
echo "\n";
}
}
}

Moving Out from AWS SES Sandbox mode:

Above Email addresses must be verified with Amazon SES. By default Your Amazon SES account has “sandbox” access.With sandbox access you can only send email to the Amazon SES mailbox simulator and to email addresses or domains that you have verified. To move out from the sandbox access, you have to request a sending limit increase. After that you will get a reply from AWS Support which is about to how you are now ensuring that your mailing list contains only recipients who specifically signed up to receive email from you. And this question arises by AWS support, if you choose YES for the option (I only send to recipients who have specifically requested my mail).

Do not worry about reply.You just do reply them “Our mailing list contains only recipients who specifically signed up to receive email from us“.Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion. if you face any issue with this code let us know. We’d love to help!