Make scp command work with cronjob

April 13, 2010 · Posted in Gentoo, Linux · 7 Comments 

For a couple of days now, I use a bash script to generate an html page and then upload it to my devspace via scp. Today, I decided to put that script to my crontab and stop running it myself every now and then.  To my surprise, cron log listed the following error after every execution of my script:

Permission denied (publickey)

However the script runs successfully when I run it myself. Googling around I run into crons’ man page:

Cron is using a very limited enviroment


Apparently the SSH_AUTH_SOCK variable that was handling my ssh connections, based on PublicKey, was missing.


Many of you already know the keychain script . If you don’t, you may seriously consider having a look on its documentation. I wont describe the procedure here though. Adding my ssh key to keychain, a new file is created, including the following variable definitions.

hwoarang@Mystical ~ $ cat ~/.keychain/Mystical-sh
SSH_AUTH_SOCK=/tmp/ssh-lKgXVi6837/agent.6837; export SSH_AUTH_SOCK;

The variable I was looking for is here :). Now all I have to do, it to source this file at the very beggining of my bash script ( just below #!/bin/bash ) and then everything works as expected :)

X11 Forwarding. How cool is that ?

November 8, 2008 · Posted in Linux · 2 Comments 

Today I had to configure a router located on remote host. This router is pure crap and it has only Web interface. No ssh,no ftp ,nothing.

So without any further thought, I dediced to fire up ssh with -X , -C options ( X forwarding, Compression ) . After that I launched konqueror (firefox couldnt start (?) )and access the routers’ web interface. Stupid? Maybe . But i couldnt think of anything else

Just for the record the ssh command I lauched was

ssh -c arcfour,blowfish-cbc -C -X

arcfour,blowfish-cbc appear to be faster according to several sources over the internet

Another great idea would be “links” but routers web interface didnt work with that :(

How would you deal with this problem? Will you use X11 Forwarding as I did? I d like to hear your ideas :)

ps:Replacing the router is not an option ! :)

Gentoo Miniconf
Patras Wireless Metropolitan Network
Planet Hellug
forum hellug