How to use the SFTP drivers in october CMS - driver

Within octoberCMS there's a plugin called Drivers to install some third party drivers for storage; I want to use the SFTP drivers from FlySystem. I've adjusted the composer file of the driver plugin and added the flysystem;
"require": {
"php": ">=7.0",
"composer/installers": "~1.0",
"aws/aws-sdk-php": "~3.0",
"pda/pheanstalk": "~3.0",
"iron-io/iron_mq": "~1.5",
"predis/predis": "~1.0",
"phpseclib/phpseclib": "~2.0",
"league/flysystem-rackspace": "~1.0",
"league/flysystem-aws-s3-v3": "~1.0",
"guzzlehttp/guzzle": "~6.3",
"league/flysystem-sftp":"~1.0"
},
After installing the plugin the vendor folder contains also the flysystem-sftp files, but when I add an sftp record to the filesystems.php file in the config folder like
'sftp' => [
'driver' => 'sftp',
'host' => 'myftp.mydomain.com',
'username' => '########',
'password' => '########',
'port' => '21',
'passive' => 'true',
],
October gives an error: "Driver [sftp] is not supported", when I try to use it. Is there any one who can help me further?

Related

Creating a binary-only Erlang release

I have created a release of my program with rebar. Navigating around in the output directory I see my Erlang source files. Is there any way to create binary only releases of Erlang programs, so that they can be distributed (as closed source) to customers?
Yes, in rebar.config file. {include_src, false} in prod section
{profiles, [
{dev1, [{relx, [{dev_mode, false},
{include_erts, false},
{sys_config, "./config/dev1/sys.config"},
{vm_args, "./config/dev1/vm.args"}]}
]
},
{prod, [{relx, [{dev_mode, false},
{include_erts, true},
{include_src, false},
{sys_config, "./config/prod/sys.config"},
{vm_args, "./config/prod/vm.args"}]}]

Error retrieving credentials from the instance profile metadata server.Failed to connect to 169.254.169.254 port 80: No route to host

I am trying to create a sub-domain using Route53 with aws-php-sdk.
but I am getting this error again and again:
[2017-06-16 12:17:00] local.ERROR: Aws\Exception\CredentialsException: Error retrieving credentials from the instance profile metadata server.
(cURL error 7: Failed to connect to 169.254.169.254 port 80: No route to host (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)) in /var/www/html/test/vendor/aws/aws-sdk-php/src/Credentials/InstanceProfileProvider.php:79
I am using aws-sdk-php version: 3.29
"aws/aws-sdk-php": "^3.29"
Here is my written code
use Aws\Route53\Route53Client;
$client = Route53Client::factory(array(
'region' => 'us-east-1',
'version' => '2013-04-01',
'credentials ' => array('key'=>'AWS_KEY',
'secret'=>'AWS_SECRET_KEY')
));
$result = $client->changeResourceRecordSets(array(
// HostedZoneId is required
'HostedZoneId' => 'ROUTER_53_HOSTED_ZONE_ID',
// ChangeBatch is required
'ChangeBatch' => array(
// Changes is required
'Changes' => array(
array(
// Action is required
'Action' => 'CREATE',
// ResourceRecordSet is required
'ResourceRecordSet' => array(
// Name is required
'Name' => 'test2.xyz.co.in.',
// Type is required
'Type' => 'A',
'TTL' => 600,
"AliasTarget"=> array(
"HostedZoneId"=> "LOAD_BALANCER_ZONE_ID",
"DNSName"=> "LOAD_BALANCER_DOMAIN_NAME",
"EvaluateTargetHealth"=> false
),
),
),
),
),
));
Help will be appreciable. Thanks in advance.
This question is very old but I want to drop an answer in case someone has a similar issue.
The AWS PHP SDK needs credentials to communicate with AWS. the credentials are known as access key ID and secret access key.
As highlighted in AWS documentation
If you do not provide credentials to a client object at the time of its instantiation, the SDK will attempt to find credentials in your environment.
According to your logs it seems that the SDK is still pulling credentials from your environment which are stored in ~/.aws/credentials, and not using the provided keys.
Either make sure you have the access key and the secret key in your environment variable.
$ less ~/.aws/credentials
[default]
aws_access_key_id = key
aws_secret_access_key = secret
Or
Clear the configuration cache to force using the explicit credentials declared in the instantiation of your client. in case they were cached.
php artisan config:cache
Also refer to this documentation on how to properly setup a client.
https://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html
If you use
php artisan config:cache
make sure you don't use env() helper for accessing env variables from anywhere except the config files (config/*). Avoid using env() helper in your blade templates. This is because, calling env() helper after the above command is run, will return null.
Instead use a config file for accessing env values. If a separate config file under the config folder is not available for that vendor package / service, The config/services.php is a good place to point to env values.
Thephp artisan config:cache command will speed up your app as the the env variables are cached and so is recommended in a production environment.
Refer Laravel Configuration Caching for more details.

AWS Elastic Beanstalk Error - Passenger

I've tried various solutions that are intuitive and then have tried the solutions that have apparently helped others. I've spun up and terminated my Rails 4 app about 10 times. So...I thought I'd turn here to see if anyone knew an answer.
Here is the log file:
[ 2015-03-06 06:12:27.0070 2619/7fa0f6d60740 agents/Watchdog/Main.cpp:538 ]:
Options: { 'analytics_log_user' => 'webapp', 'cleanup_pidfiles' =>
'L3RtcC9wYXNzZW5nZX*********************yL3RlbXBfZGlyX3RvdWNoZXIucGlk',
'default_group' => 'webapp', 'default_python' => 'python', 'default_ruby' =>
'/opt/rubies/ruby-2.1.5/bin/ruby', 'default_user' => 'webapp', 'log_level' =>
'0', 'max_pool_size' => '6', 'passenger_root' => '/tmp/passenger-
standalone.1fcb7jr/locations.ini', 'passenger_version' => '4.0.53',
'pool_idle_time' => '300', 'prestart_urls' => 'aHR0cDovLzAuMC4wLjA6ODAA',
'temp_dir' => '/tmp', 'union_station_gateway_address' =>
'gateway.unionstationapp.com', 'union_station_gateway_port' => '443',
'user_switching' => 'false', 'web_server_passenger_version' => '4.0.53',
'web_server_pid' => '2618', 'web_server_type' => 'nginx',
'web_server_worker_gid' => '496', 'web_server_worker_uid' => '497' }
[ 2015-03-06 06:12:27.3877 2622/7fac802f6740 agents/HelperAgent/Main.cpp:650]:
PassengerHelperAgent online, listening at
unix:/tmp/passenger.1.0.2618/generation-0/request
[ 2015-03-06 06:12:28.2222 2630/7fe1e0b67740 agents/LoggingAgent/Main.cpp:321
]: PassengerLoggingAgent online, listening at
unix:/tmp/passenger.1.0.2618/generation-0/logging
[ 2015-03-06 06:12:28.2223 2619/7fa0f6d60740 agents/Watchdog/Main.cpp:728 ]:
All Phusion Passenger agents started!
2015/03/06 06:12:29 [error] 2638#0: *3 "/var/app/current/public/index.html" is
not found (2: No such file or directory), client: 127.0.0.1, server: _,
request: "HEAD / HTTP/1.1", host: "0.0.0.0"
2015/03/06 06:13:35 [error] 2638#0: *7 "/var/app/current/public/index.html" is
not found (2: No such file or directory), client: 172.3*.**.***, server: _,
request: "GET / HTTP/1.1", host: "****************-env.elasticbeanstalk.com"
I have gem 'passenger' in my gem file...I have tried in both development (because I've seen a number of errors with production and passenger) and production and I swear I have never had this kind of trouble uploading to elastic beanstalk. In fact this is a very stripped down app with only a static page and both devise for a user and devise for active admin. No errors or problem in either environment on my local machine.
I've never even realized I needed the index.html file...I always assumed that was only in php and other languages and that Rails took care of that for you with root. And like I said I've never seen this problem before. So to test that I put in an index.html file in the public folder and I could see that ahead of my root route on my local machine, but still no dice in AWS. I'd prefer to be able to drop this in and one of the other configs like just Puma. And I see a Puma and Nginx config available, but not in the GUI which is what I was planning to just "drop" this in and be done with it for the time being. I'm using a t2.small instance.
Any help or direction would be greatly appreciated. Thanks.
UPDATE: I've now tried this pushing through Git using Puma...etc. Trouble everywhere. It makes no sense. I even moved it to a "Hello World" app and still nothing. I'm about done with AWS. This is ridiculous. Nearly worse than an iOS release that has massive problems every year.
Ok. After today I have gotten this taken care of and hosted properly. In case this helps someone out...here were the key takeaways:
1) There is a Puma option if you are using CLI that is obvious. There is ALSO an option in the GUI, however it reads like a sentence instead of a logical select box. It DOES exist on the front page underneath the selection of the language to be installed. If you are getting a Passenger Error and expect to be using Puma, this is something you need to change.
2) I had installed a User model that contained an ActiveAdmin role as well. ActiveAdmin was pulling the gem from GitHub and I am using a machine with GitHub installed already. This really was the problem...switching to production and onto ElasticBeanstalk I forgot that git wasn't already installed. After going back through the errors many times, the common error was
# :github => 'activeadmin/activeadmin'+ '[' -d /vendor/cache ']'
+ bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
You need to install git to be able to use gems from git repositories.
[CMD-Startup/StartupStage0/AppDeployPreHook/10_bundle_install.sh] : Activity failed.
This is located in the eb-activity.log.
So, if this is similar to anything happening to you, you can do as follows:
1) start up your instance with the correct server.
2) if you get an error, look through that activity log mentioned above. (All the logs for that matter)
3) If the error fails similarly there is NO NEED to delete the instance. Leave it running.
4) SSH into the server instance that you just created. Run
sudo yum update
that is more than likely recommended. And then run
sudo yum install git
5) Upload the same exact file and name the version 0.1 and when it's through it should be green if this was your only error. Click the link and Voila.
For the git binary problem: It will fail again, if more instances are spinning up. You can avoid that by adding a config under $ROOT/.ebextensions which will be used for any new instance.
# Install git in order to be able to bundle gems from git
packages:
yum:
git: []

RuntimeError (Location of wkhtmltopdf unknown)

I am trying to use pdf generator in my rails 2.3app. It is working fine
in my local machine and pdf is generating. In my production server (nginix) it is not working and shows the error:
"wkhtmltopdf RuntimeError (Location of wkhtmltopdf unknown)"
In the config/initializers/wicked_pdf.rb.example file I have mentioned the path to the binary exe file as:
WickedPdf.config = {
:wkhtmltopdf => '/opt/wkhtmltopdf-amd64',
:layout => 'pdf.html'
:header => {:html => {:template=> 'layouts/pdf_header.html'}}
}
And in the opt folder there is wkhtmltopdf-amd64 binary exe file.
:wkhtmltopdf => '/opt/wkhtmltopdf-amd64',
This is your system opt folder, check whether this folder has permission to execute the binary.
Alternatively change the location of wkhtmltopdf into your rails application by extracting it to /path/to/rails_app/bin
and then change your initializer to :wkhtmltopdf => Rails.root.join('bin', 'wkhtmltopdf-amd64').to_s
can we replace the path with installed gem at gemset?
At terminal just check 'which wkhtmltopdf' is installed in our app gemset path.Then replace the path your wkhtmltopdf initializer with that.

can't access ec2 instance which is created by ruby aws-sdk lib using ssh?

i'm using ruby aws-sdk to launch instance in amazone EC2 but i have problem with access the created instances using ssh, here what i did
ec2 = AWS::EC2.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY, :ec2_endpoint => "ec2.sa-east-1.amazonaws.com")
securitygrp = ec2.security_groups.create('mysecgrp')
securitygrp.authorize_ingress(:tcp, 22)
ec2.instances.create(:image_id => "ami-082df215")
but i can't access the instance using ssh root#ip_address, i got connection timed out, is there something i missing, please anyone help me?
When you launch an instance, you may optionally provide the security group. If you omit the :security_groups options, then it will default to the "default" security group (you can not change the security group of an instance after launch). In your example you should be specifying the security group to the one you just created.
Another thing to consider is specifying the key pair. It will default to one if you don't set it, but you will likely need this to log into a public ami.
Here is an example I just ran. The AMI I use is the amazon linux ami.
AWS.config(:access_key_id => '...', :secret_access_key => '...')
ec2 = AWS::EC2.new(:ec2_endpoint => "ec2.sa-east-1.amazonaws.com")
# create a security group and authorize ssh
sg = ec2.security_groups.create('my-security-group')
sg.authorize_ingress(:tcp, 22)
# create a key pair and write it to disk
key_pair = ec2.key_pairs.create('my-key-pair')
File.open("#{ENV['HOME']}/.ssh/my-key-pair.pk", 'w') do |file|
file.write key_pair.private_key
end
require 'fileutils'
FileUtils.chmod(0600, "#{ENV['HOME']}/.ssh/my-key-pair.pk")
instance = ec2.instances.create(
:image_id => 'ami-3c3be421',
:key_name => key_pair.name,
:security_groups => [sg])
sleep 1 while instance.status == :pending
puts instance.ip_address
#=> '1.2.3.4'
Now you should be able to ssh into the instance (sometimes there is a ~ 30 second delay from when the instances status is :available and when it responds to ssh).
# some amis require you to login as root, others as ec2-user
$ ssh -i ~/.ssh/my-key-pair.pk ec2-user#1.2.3.4

Resources