linux - Run wget command via ssh remotely but connection timeout -


i've been struggling 2 days already.

i have 2 linux machines , b , trying run following command remotely (as done on b locally):

sshpass -p 'somepassword' ssh username@machineb "wget http://someurl.com/somefile.zip"

somefile.zip should downloaded , kept on b connection timeout. running command directy on macnine b works fine. presume there issues ssh.

this script needed teamcity continous integration.

p.s. sshpass utility run command via ssh without user interaction specifying password.

what issue , how fix it? thank you.

update: proxy settings should specified in ~/.bashrc file non-interactive sessions. reason proxy setting in /etc/profile works interactive sessions.

i've not tried sshpass, guess connection timeout connecting b, not b making http request. suggest using ssh keys instead, i'm pretty sure work you.

to setup ssh keys, run command on a:

ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -n ''

the above create ssh rsa keypair 4096 bits in length no passphrase (-n ''). writes 2 files in ~/.ssh; copy public key b:

scp ~/.ssh/id_rsa.pub b:

on server b this:

mkdir ~/.ssh chmod 0700 ~/.ssh cat id_rsa.pub >> ~/.ssh/authorized_keys chmod 0600 ~/.ssh/authorized_keys

on redhat systems have selinux enabled, may necessary run following command in order system accept using authorized keys file:

restorecon -r -v ~/.ssh

the above allows server containing private key of public key listed in authorized_keys file ssh machine.

once have setup, should able ssh b without password.

the following command works on system via cronjob:

ssh -i ~/.ssh/id_rsa foobar.local 'curl -o https://www.google.com/logos/doodles/2014/rubiks-cube-5658880499515392-res.png'


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -