I am new to crontab. My end goal is to make a git pull command every 10 minutes, but in debugging I tried just sending an email to myself using echo:
MAILTO=[my email]
*/10 * * * * echo 'Joseph is the best'
I don't get any email though...
Crontab does not magicly sends emails out of the box. You need to set up a smtp server first. If you don't want to host your own server you can user google mail and relay all emails over your google account. I use ssmtp and mailutils for this.
A quickguide:
sudo apt-get install ssmtp
sudo vim /etc/ssmtp/ssmtp.conf
than enter your details at the bottom:
mailhub=smtp.gmail.com:587
useSTARTTLS=YES
AuthUser=username-here
AuthPass=password-here
EDIT: for this to work you will have to enable "allow acces to less secure apps" in your google settings
Related
I'm trying to get daemons to send email from a Debian 10 Server.
I'm using msmtp-mta with an OVH SMTP server. It's properly configured.
Everything works fine when sending email directly via the mail command, like so :
echo "test" | mail -s "test" email#domain.com
However, some daemons like smartd try to send email to root#localhost, but with a malformed recipient address root, which the OVH SMTP doesn't like at all :
send-mail: recipient address root not accepted by the server
send-mail: server message: 501 5.1.3 Invalid address
send-mail: could not send mail (account default from /etc/msmtprc)
Can't send mail: sendmail process failed with error code 65
and in the msmtp log :
Apr 25 00:39:49 host=ssl0.ovh.net tls=on auth=on user=***REDACTED*** from=***REDACTED*** recipients=root smtpstatus=501 smtpmsg='501 5.1.3 Invalid address' errormsg='recipient address root not accepted by the server' exitcode=EX_DATAERR
I tried adding root: email#domain.com to /etc/aliases adn relaoding with newaliases, and even put a .forward in root's homedir.
Has anyone experienced this before ? Shouldn't msmtp honor /etc/aliases and/or .forward and replace root's email address ?
Please check with msmtp -v if you have another alias that might override the one you're settings. You'll be able to check if it correctly register your aliases using that command.
You may also want to add aliases /etc/aliases to your /etc/msmtprc file.
You may also add a default alias in /etc/aliases if you would like all the mails to be send with a from corresponding: default: awesome.mail#example.tld
How do i set the cron command in Cpanel in Linux server i use this it works for me is there any proper way
wget http://www.vloghit.com/crons/send_mail
You should use the full path for wget like /usr/bin/wget instead of just plain wget. Depending on the WHM server configuration the crons might be running as jailed so you might get an error stating that wget command was not found if you do not use the full path to the binary. You are also supposed to receive an email notification from that cron job. Are you geting it? I'm asking because in those email notifications you get also an error message that can help you to understand why the cron was not working.
Hi I have RHEL5 with ssmtp installed on it ssmtp-2.61-22.el5.i386.rpm
my /etc/ssmtp/ssmtp.conf updated as below :-
AuthUser=mymail#gmail.com
AuthPass=mypassword
FromLineOverride=YES
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
UseTLS=Yes
RewriteDomain=gmail.com
also revaliases updated as below :
root:mymail#gmail.com:smtp.gmail.com:587
i have shutdown sendmail service
when i try to send email with ssmtp i get below error
[root#ctmtest ssmtp]# echo "test" | ssmtp -vvv mymail#gmail.com
[<-] 220 smtp.gmail.com ESMTP v26sm42795996pfi.56 - gsmtp
[->] EHLO ctmtest
[<-] 250 SMTPUTF8
[->] STARTTLS
[<-] 220 2.0.0 Ready to start TLS
ssmtp: Cannot open smtp.gmail.com:587
i searched lots of tag with this error , but unable to fix this
my system is able to connect smtp.gmail.com on port 587
[root#ctmtest ssmtp]# telnet smtp.gmail.com 587
Trying 74.125.200.108...
Connected to smtp.gmail.com (74.125.200.108).
Escape character is '^]'.
220 smtp.gmail.com ESMTP o90sm11695907pfi.17 - gsmtp
is there anyone who have fixed this ? please suggest
I encountered the same problem. The following steps worked for me:
sudo vi /etc/ssmtp/ssmtp.conf
Add the following:
TLS_CA_FILE=/etc/pki/tls/certs/ca-bundle.crt
root=XXXX#gmail.com
mailhub=smtp.gmail.com:587
AuthUser=XXXX
AuthPass=XYXYX
UseSTARTTLS=Yes
UseTLS=Yes
hostname=AAAA
Replace:
XXXX- username(mail)
XYXYX- password(mail password)
AAAA- hostname(get by running $hostname)
sudo vi /etc/ssmtp/revaliases
Add the following:
root:XXXX#gmail.com:smtp.gmail.com:587
Replace :
XXXX - username(mail)
Try running the mail now:
$mail -s "adasdas" XXXX#gmail.com
CC:
XYZLoremIpsum
.
'ctrl+D'
It solved my problem.
Hopefully for a system(Office) you need to configure correct proxy settings otherwise you will get an error:
cannot send message: Process exited with a non-zero status
try changing this option
Allowing less secure apps to access your account
https://support.google.com/accounts/answer/6010255?hl=en
This is perhaps because you're not setting the hostname parameter of ssmtp.conf. It should be a resolvable, fully-qualified domain name; yours is defaulting to the machine name of ctmtest (as shown in the EHLO command that you quote above).
The issue that user963 mentions in their answer may also be in action here, but in that case you'll get a different error message, something like ssmtp: Authorization failed (534 5.7.14 ...).
This should be a comment on Haider Raza's answer, but I am short of 1 rep point to comment lol.
From https://superuser.com/questions/431539/special-characters-in-ssmtp-password
ssmtp has bugs parsing passwords containing '=', ':' or '#'. You can use the following workaround:
feed the password directly in the command line argument
ssmtp -ap "Hash#Password" ...
alternatively put the password in an environment variable.
ssmtp -ap $PASSWD ...
Hope it helped.
first to get your hostname type in terminal : hostname
copy it and past in hostname parameter in ssmtp.conf
On my Gentoo Linux system, the error ssmtp: Cannot open smtp.server.com:port was caused by an ownership/permissions issue: the file /etc/ssmtp/ssmtp.conf should belong to the group ssmtp, which it didn't (and any user allowed to access ssmtp should be a member of that group).
I ws looking for a solution for cacti smtp mail sender.
And found myself actually sending an email using the postfix service .
I also used localhost in the postfix config.
Thanks!
This is my config for outlook365.com that works on Centos 6.10 (Final) - replace all [square brackets] with your own settings:
/etc/ssmtp/ssmtp.conf
root=[admin_emailemail#domain.ext]
mailhub=smtp.office365.com:587
RewriteDomain=[domain.ext]
# to find out run hostname command in shell
Hostname=[hostname_or_domain]
AuthUser=[your_smtp_authentication_mailbox#domain.ext]
AuthPass=[your_password]
AuthMethod=LOGIN
FromLineOverride=YES
UseTLS=YES
UseSTARTTLS=YES
# Use SSL/TLS certificate to authenticate against smtp host.
# When enabled it was failing to send emails
#UseTLSCert=YES
TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt
/etc/ssmtp/revaliases
root:[your_sender_or_authentication_mailbox#domain.ext]:smtp.office365.com:587
Mail functions are all highly broken, so are the numerous tutorials on the internet.
This is pretty bad, for something that MUST be EASY for BEGINNERS.
A little panels of unclear errors you will face:
mailx: unrecognized option '-d'
💩
mailx: unrecognized option '-v'
💩
s-nail: Setting up PseudoRandomNumberGenerator: *SSL RAND_*
s-nail: New-style URL used without *v15-compat* being set
/home/you/dead.letter 3/106
s-nail: ... message not sent
💩
s-nail: Connecting to XX.XX.XX.XXX:465 ... connected.
s-nail: SMTP: Resource temporarily unavailable
💩
s-nail: Obsoletion warning: Use of old-style credentials, which will vanish in v15!
💩
s-nail: Obsoletion warning: please don't use *smtp*: assign a smtp:// URL to *mta*!
💩
s-nail: Unexpected EOF on SMTP connection
💩💩💩
No, there is no needs of any credentials to send a simple mail.
STEP 1: Install mail-utils
sudo apt install mailutils
STEP 2: Install mutt
sudo apt install mutt
STEP 3: Run the postfix setup
sudo dpkg-reconfigure postfix
Usage press TAB to select OK
Select "Internet site"
Enter your domain, or whatever
Leave all other settings as default. (Press RETURN till the end)
Mails will then be sent from this email: yourCurrentsession#whatever.com
STEP 4: Apply settings
service postfix reload
STEP 5: Send email
echo "Hello world" | mutt -s "Message sent at $(date)" recipient#gmail.com -y
STEP 6: Optional. Change sender email and name. Create a .muttrc file in the home folder.
echo -e "set from = \"aname#something.net\"\nset realname = \"Yay\"" > ~/.muttrc
I am trying to connect to a new user account I created via SSH with the command
useradd -s /bin/false -d /home/username james
I added/edited the password via SSH with the command
passwd james
When trying to connect to my server using this user and pass via FileZilla I get the following error messages.
Response: 331 User James OK. Password required
Command: PASS *****
Response: 530 Login authentication failed
Error: Critical error
Error: Could not connect to server
When I try to login with this user/pass through SFTP I get the following error messages
Status: Connected to domain.com
Error: Connection closed by server with exitcode 1
Error: Could not connect to server
Either way it seems it doesn't allow me to use this newuser anywhere.
My server details
Linux 2.6.18-308.11.1.el5 GNU/Linux
(Red Hat 4.1.2-52)
Centos
Regarding FTP, the FTP server commonly used on Linux systems requires users to have a shell that's listed in the file /etc/shells. For example, this online ftpd man page says that, among other things, "The user must have a standard shell returned by getusershell(3).". The page for getusershell() shows that it reads shells from /etc/shells.
You could probably make FTP work adding /bin/false to /etc/shells. Your Linux system might have a more suitable shell available, like /usr/sbin/nologin.
Regarding SFTP, the ssh server normally provides SFTP service by by invoking a program called sftp-server. If you examine the server's sshd_config file, you'll probably find a line like this:
Subsystem sftp /usr/lib/openssh/sftp-server
sshd runs the subsystem program as a shell command, using the user's shell. If you set the user's shell to /bin/false, then sshd ends up running the command:
/bin/false -c /usr/lib/openssh/sftp-server
/bin/false ignores its command-line arguments and exits with code 1, so the SFTP client's session drops immediately after it starts.
sshd has an internal SFTP server component that can be used instead of the external program. The usual way of limiting SSH access to SFTP for some users is to set up a Match group within sshd_config, forcing the internal-sftp command for certain classes of users. Here are a couple examples of that:
http://en.wikibooks.org/wiki/OpenSSH/Cookbook/SFTP#SFTP-only_Accounts
https://serverfault.com/questions/354615/allow-sftp-but-disallow-ssh
Dont use "-s /bin/false". Use "-s /sbin/nologin" instead and it should be fine.
Make sure your account password hasn't expired. Mine did, and Filezilla exited with error code 1.
After logging onto the server and updating the account password (prompted immediately after connecting), I am now able to connect with SFTP & Filezilla.
Probably is a password related issue, check account
chage -l <user>
account must not be expired.
FTP doesn't allow /usr/sbin/nologin user
Response: 220 Welcome to the Scent Library's File Service.
Command: USER ftpuser
Response: 331 Please specify the password.
Command: PASS ******
Response: 530 Login incorrect.
filezilla 530 error - but password is correct
vsftpd: 530 Login incorrect
530 Login or password incorrect!
How can I connect via FTP using FileZilla? I get a 530 error.
Response: 220 Welcome to Test FTP service.
Command: USER ftpuser
Response: 331 Please specify the password.
Command: PASS ******
Response: 530 Login incorrect.
Error: Critical error
Error: Could not connect to server
Change user's shell
usermod -s /usr/sbin/nologin username
Then edit "/etc/shells" file and add this line
/usr/sbin/nologin
In order to connect to the server using ftp, you also need to run a ftp server / service or daemon.
An example of such ftp server is "vsftpd"
After installing it, you will also need to configure it and allow anonymous ftp access or ftp access to existing users
You will find the configuration file in the path "/etc/vsftpd/vsftpd.conf"
The below link might be useful for you --
https://www.digitalocean.com/community/tutorials/how-to-set-up-vsftpd-on-centos-6--2
I am new to SSH and Linux and I hope someone can help. I am working on a site with a dedicated server (VPS) and I am also working with WordPress. I used SSH to log into the site's files with Cyberduck (I've also used FileZilla successfully) and install WordPress on the server.
The problem I'm having now is that I can't edit or add any plugins or files on WordPress because WordPress doesn't have access to the site's FTP which is standard. It asks for credentials and when I attempt to enter them into the WordPress dashboard, it doesn't work. There is an option for FTP and there is an option for FTPS (SSL). I know these are different than SSH but I tried the SSH credentials anyway and obviously they didn't work.
I then logged into the SSH through Mac Terminal and did the instructions here:
1. Login as root through SSH.
2. Next add the user account you want using the 'useradd' command
useradd <username>
3. Now create a special group for that user.
groupadd <groupname>
4. Now to add the user to the group
gpasswd -a <username> <groupname>
5. Change the group ownership of the special directory to that group.
chgrp -R groupname
/path/to/your/web/directory
6. Enable write permissions
chmod -R g+rw
/path/to/your/web/directory
And it worked. I was able to add a new user (and I could confirm this by looking at the /etc/passwd file). I then logged out and tried to log in with Cyberduck using the new credentials and setting it to FTP (instead of SSH) and it didn't work. It did however work to log in with SSH with the new user credentials. So it seems I can successfully add a new SSH user but not a new FTP user.
I need the user to be FTP so I can hook WordPress up and begin editing. How do I specific the user to be FTP as opposed to SSH? Thanks for any help!
I've found an answer to my question and figured I'd document here for anyone else who runs across this issue. It's surprisingly easy.
Just go to this link and download the plug-in:
http://wordpress.org/plugins/ssh-sftp-updater-support/
You obviously have to upload this straight into your WordPress directory in the SFTP (/wp-content/plugins) in order for it to work correctly since it won't work from within the WordPress dashboard.
Once those files are there, when WordPress prompts you to login to your 'FTP' it will have an option for SSH which you can select and log-in. Voila!