scp with a key

SCP is a secure copy utility in Linux. You’ll need access to your system. In this example, a pem key is used to authenticate to a host. SCP copies filename.ext to the home directory of ec2-user. It’s important to add the target directory, otherwise it will not work. Here’s how to use SCP with a key from local to server. scp -i key.pem filename.ext user@server:/home/user From server to local. Run the command from local machine. ...

October 22, 2020 · 1 min · ulysses

aws s3 make object public

Copy object or file to S3 bucket. aws s3 cp filename.ext s3://bucketname/ --profile your-profile To make it publicly available, run this command. aws s3api put-object-acl \ --bucket bucket-name \ --key filename.ext \ --acl public-read \ --profile your-profile

October 21, 2020 · 1 min · ulysses

openssl upgrade

Here’s how to upgrade to OpenSSL 1.1 on Redhat/Centos. # check openssl version yum info openssl # download and install cd /usr/local/src wget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz tar -zxf openssl-1.0.2-latest.tar.gz # compile cd openssl-1.0.2a ./config make make test make install # update softlink mv /usr/bin/openssl /root/ ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl # verify new version openssl version

October 19, 2020 · 1 min · ulysses

ssh script

Here’s my custom ssh script named login.sh using multiple arguments. #!/bin/bash if [ $# -eq 0 ] then echo 'no server supplied' exit 1 fi INPUT=$2 case "$INPUT" in abc) ssh user1@$1 ;; def) ssh user2@$1 ;; *) ssh user3@$1 ;; esac How to use with expected outputs. ./login.sh no server supplied ./login.sh server3 abc ssh user1@server3 ./login.sh server2 def ssh user2@server2 ./login.sh server1 ssh user3@server1

October 15, 2020 · 1 min · ulysses

aws enable enhance network support

When changing machine types, you may be asked to enable the latest ENA driver for Enhanced Network Support on an Amazon EC2 instance. There are several instructions depending on the Linux OS flavor. Here are the instructions to enable. In some cases, you may need to rebuild the kernel module. To verify that the ena module is installed, use the modinfo command as shown in the following example. modinfo ena You also may have to enable the enhanced networking attribute on the instance. ...

October 13, 2020 · 1 min · ulysses

aws s3 acceleration cli

Here is how to enable Amazon S3 Transfer Acceleration on a S3 bucket. aws s3api put-bucket-accelerate-configuration \ --bucket bucketname \ --accelerate-configuration Status=Enabled \ --region us-east-1 Use an accelerate endpoint. aws configure set default.s3.use_accelerate_endpoint true To copy files to S3 you can use the default copy. aws s3 cp file.txt s3://bucketname/keyname \ --region us-east-1 Or use the acceleration endpoint. aws configure set s3.addressing_style virtual aws s3 cp file.txt s3://bucketname/keyname \ --endpoint-url http://s3-accelerate.amazonaws.com \ --region us-east-1

October 4, 2020 · 1 min · ulysses

aws update acm certs

Here’s how to update AWS Certificate Manager SSL Cert. #!/bin/bash cd /etc/letsencrypt/live/domain.com/ arn='arn:aws:acm:us-east-1:xxxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' aws acm import-certificate \ --certificate fileb://cert.pem \ --certificate-chain fileb://chain.pem \ --private-key fileb://privkey.pem \ --certificate-arn $arn \ --region us-east-1 You can run this every time certbot updates your certificate. Or you can schedule it in crontab.

October 4, 2020 · 1 min · ulysses

efs infrequent access

Just like in S3, you can have to up to 92% in savings if you use Infrequent Access or IA with AWS EFS (Elastic File Storage). You can create a lifecycle policy to move data from standard storage to infrequent access. Files that are not being used after x number of days are then moved to Infrequent Access. The downside is, the data in IA do not count towards gaining burst credits. You will need to keep a certain amount of standard storage to prevent depleting your burst credits. ...

October 4, 2020 · 1 min · ulysses

gcp create internal ip reservation

Here’s how to create an internal IP reservation in GCP. gcloud compute addresses create my-private-ip-reservation \ --addresses 10.128.0.15 \ --region us-central1 \ --subnet default \ --project project-id To list your reserved IPs. gcloud compute addresses list \ --project project-id

September 29, 2020 · 1 min · ulysses

gcp list instances with service account

Here’s how to list GCP instances with a specific service account. gcloud compute instances list \ --project your-project-id \ --format="value(name,serviceAccounts[].email)" \ --filter="serviceAccounts.email=your-service-account@email.com AND name~\bwp" I’m using filters to look for a specific service account, and any instance starting with ‘wp.’ \b means begins with.

September 23, 2020 · 1 min · ulysses