SnapOverflow

SnapOverflow Logo SnapOverflow Logo

SnapOverflow Navigation

  • Home
  • Server
  • Ubuntu

Mobile menu

Close
  • Home
  • System Administrators
    • Hot Questions
    • New Questions
    • Tags
  • Ubuntu
    • Hot Questions
    • New Questions
    • Tags
  • Help
Home / user-58008

binaryorganic's questions

Martin Hope
binaryorganic
Asked: 2014-07-24 07:51:59 +0800 CST

Can't run AWS CLI from CRON (credentials)

  • 35

Trying to run a simple AWS CLI backup script. It loops through lines in an include file, backs those paths up to S3, and dumps output to a log file. When I run this command directly, it runs without any error. When I run it through CRON I get an "Unable to locate credentials" error in my output log.

The shell script:

AWS_CONFIG_FILE="~/.aws/config"

while read p; do
 /usr/local/bin/aws s3 cp $p s3://PATH/TO/BUCKET --recursive >> /PATH/TO/LOG 2>&1
done </PATH/TO/INCLUDE/include.txt

I only added the line to the config file after I started seeing the error, thinking this might fix it (even though I'm pretty sure that's where AWS looks by default).

Shell script is running as root. I can see the AWS config file at the specified location. And it all looks good to me (like I said, it runs fine outside of CRON).

bash
  • 14 Answers
  • 47167 Views
Martin Hope
binaryorganic
Asked: 2014-06-03 10:43:05 +0800 CST

Shell script only executes partially when run with CRON [duplicate]

  • 0
This question already has answers here:
Why is my crontab not working, and how can I troubleshoot it? (7 answers)
Closed 8 years ago.

I've written a shell script that does the following:

  • Retrieve mail from a POP3 account (using GetMail)
  • Save a copy of that email to S3 (using AWS CLI)
  • Email me the filesize of the email

The script runs fine manually, and technically runs from CRON, but it only seems to be sending the email. The getmail and S3 bits don't seem to run.

Everything I've read seems to hammer home the message that I need to be careful about relative paths and the like when using CRON, but I think I'm using absolute paths everywhere I need to be, so I'm stumped as to what the issue could be.

My Shell Script is here:

#!/bin/bash

# Run GetMail
getmail -r /PATH/TO/EMAIL/getmail.email

# Save to S3
aws s3 cp /PATH/TO/SCRIPT/email-backup.mbox s3://XXXXXXXXXX/email-backup.mbox 

# Send Confirmation Email

SUBJECT="EMAIL SUBJECT"
EMAIL="[email protected]"

# Get current filesize
FILENAME=/PATH/TO/SCRIPT/email-backup.mbox
FILESIZE=$(stat -c%s "$FILENAME")

# Email Content
EMAILMESSAGE="/tmp/emailmessage.txt"
echo "EMAIL BODY" >$EMAILMESSAGE
echo "" >>$EMAILMESSAGE
echo "Current File Size: $FILESIZE bytes" >>$EMAILMESSAGE

# Send the Mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
bash
  • 1 Answers
  • 1716 Views
Martin Hope
binaryorganic
Asked: 2013-09-25 03:13:31 +0800 CST

Permissions error trying to dump Redis to a Vagrant shared folder

  • 0

I keep getting a permissions error when trying to dump the Redis .rdb file to my vagrant shared folder. The saves are working fine when going to the default /var/lib/redis location.

A few things I've tried (suggested in various forums / threads):

1) adding the following to /etc/init.d/redis-server:

USER=vagrant
GROUP=vagrant

2) Changing the umask flag to 022 in /etc/init.d/redis-server

3) Opening up permissions on the vagrant shared folder itself.

Pretty sure this one's just going over my head and that I'm doing something wrong. Spent 2 or 3 hours on it though and am starting to lose hair ;)

vagrant
  • 2 Answers
  • 645 Views
Martin Hope
binaryorganic
Asked: 2012-03-01 07:40:12 +0800 CST

Is this script nefarious?

  • 0

This is sitting in my web site's cgi-bin. Should I be concerned about it?

    #!/usr/bin/perl

print <<HTML;
Content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html">
<link rel="stylesheet" type="text/css" href="../../css/style.css">
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0">
<tr class="subhead" align="Left"><th>Name</th><th>Value</th></tr>
HTML

my $class;

foreach (sort keys %ENV) {
    next unless /^HTTP_|^REQUEST_/;
    $class = ($class ne 'normal')? 'normal': 'alt';
    print <<HTML;
<tr class="$class"><td valign="top">$_</td><td>$ENV{$_}</td></tr>
HTML
}

print <<HTML;
</table>
</body>
</html>
HTML
cgi security perl cgi-bin
  • 2 Answers
  • 245 Views
Martin Hope
binaryorganic
Asked: 2011-10-09 07:10:50 +0800 CST

How do I do an .htaccess 301 redirect of a query string?

  • 2

I'm trying to redirect a url http://domain.com/?p=106 to http://domain.com/?p=110

My .htaccess file looks like this:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^p=106
RewriteRule / http://domain.com/\?p=110 [L,R=301]

But I can't seem to get it to work.

.htaccess mod-rewrite querystring 301-redirect
  • 2 Answers
  • 701 Views
Martin Hope
binaryorganic
Asked: 2011-10-05 06:45:25 +0800 CST

RSync shell script failing to run as CRON, runs fine manually

  • 0

I have a simple shell script that runs Rsync. It runs fine if I call it manually from the command line, but when I set it up as a CRON job I get the following error:

rsync: failed to open exclude file exclude.txt: No such file or directory (2)
rsync error: error in file IO (code 11) at exclude.c(1000) [client=2.6.8]

I use the following in the shell script:

--exclude-from 'exclude.txt'

The file exists and the script runs fine (honoring the exclusions) when run manually. The shell script being called by the CRON job and exclude.txt are in the same directory.

The entire script I'm trying to run looks like this:

rsync -avrhgo --exclude-from 'exclude.txt' --progress --stats --delete-excluded -e "ssh -p XXXXX" / XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
cron ssh rsync shell-scripting
  • 1 Answers
  • 1200 Views
Martin Hope
binaryorganic
Asked: 2011-09-26 16:12:00 +0800 CST

Despite all the information available, I'm stumped on passwordless logins. Help?

  • 0

So I have my home computer & a server. I want the server to be able to SSH into my home computer w/out a password. I have followed various tutorials and can ssh from home to server with no password. Everything works fine. When I try to reverse the process and ssh from server to home I get a permission denied (publickey) error. I can log in to both machines using a password just fine.

The relevant bits from a verbose attempt are as follows:

   debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Offering public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: No more authentication methods to try.
Permission denied (publickey,keyboard-interactive).

My /etc/ssh/sshd_config file on the home PC looks like this:

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile  ~/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords yes

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication yes

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM no

The home PC is running Ubuntu and the server is CentOS.

centos ubuntu security ssh rsa
  • 4 Answers
  • 4337 Views
Martin Hope
binaryorganic
Asked: 2010-11-13 17:59:31 +0800 CST

Does phpmyadmin create use its own database?

  • 1

I just ran a quick check of all installed databases on my system (something I'd never done before) and I recognized all of them except for one. The database name is phpmyadmin_[random string]. I'm just being paranoid here and want to make sure that such a database belongs on my system (I do, for the record, have and use PHPmyadmin).

mysql php
  • 1 Answers
  • 583 Views
Martin Hope
binaryorganic
Asked: 2010-10-26 08:45:39 +0800 CST

How do I tell Git for Windows where to find my private RSA key?

  • 543

My Git setup runs fine on Linux, but when I try to set things up under Windows (using Git for Windows and TortoiseGit), I don't know where to put my private SSH key (or, better still, how to tell ssh where it's located). I'm using the standard ssh.exe option during installation of Git for Windows. The setup runs fine if I allow password authentication (in lieu of RSA) on the server.

windows ssh rsa git private-key
  • 30 Answers
  • 1076523 Views
Martin Hope
binaryorganic
Asked: 2010-10-23 19:11:32 +0800 CST

I'm having trouble restarting openssh server

  • 0

I'm trying to restart openssh-server in Ubuntu 10.10 by typing:

sudo /etc/init.d/ssh restart

and I'm getting this error:

sudo: unable to execute /etc/init.d/ssh: Text file busy
command-line-interface ssh
  • 4 Answers
  • 1776 Views

Sidebar

Stats

  • Questions 681965
  • Answers 980273
  • Best Answers 280204
  • Users 287326
  • Popular
  • Answers
  • Marko Smith

    Can you pass user/pass for HTTP Basic Authentication in URL parameters?

    • 5 Answers
  • Marko Smith

    Ping a Specific Port

    • 18 Answers
  • Marko Smith

    Check if port is open or closed on a Linux server?

    • 7 Answers
  • Marko Smith

    How to automate SSH login with password?

    • 10 Answers
  • Marko Smith

    How do I tell Git for Windows where to find my private RSA key?

    • 30 Answers
  • Marko Smith

    What's the default superuser username/password for postgres after a new install?

    • 5 Answers
  • Marko Smith

    What port does SFTP use?

    • 6 Answers
  • Marko Smith

    Command line to list users in a Windows Active Directory group?

    • 9 Answers
  • Marko Smith

    What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats?

    • 3 Answers
  • Marko Smith

    How to determine if a bash variable is empty?

    • 15 Answers
  • Martin Hope
    Davie Ping a Specific Port 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    Smudge Our security auditor is an idiot. How do I give him the information he wants? 2011-07-23 14:44:34 +0800 CST
  • Martin Hope
    kernel Can scp copy directories recursively? 2011-04-29 20:24:45 +0800 CST
  • Martin Hope
    Robert ssh returns "Bad owner or permissions on ~/.ssh/config" 2011-03-30 10:15:48 +0800 CST
  • Martin Hope
    Eonil How to automate SSH login with password? 2011-03-02 03:07:12 +0800 CST
  • Martin Hope
    gunwin How do I deal with a compromised server? 2011-01-03 13:31:27 +0800 CST
  • Martin Hope
    Tom Feiner How can I sort du -h output by size 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich What is a Pem file and how does it differ from other OpenSSL Generated Key File Formats? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent How to determine if a bash variable is empty? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus How do you find what process is holding a file open in Windows? 2009-05-01 16:47:16 +0800 CST

Related Questions

Trending Tags

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Home
  • Questions
    • Hot Questions
    • New Questions
  • Tags
  • Help

Footer

SnapOverflow

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Help

© 2022 SOF-TR. All Rights Reserve