I am trying to configure a remote Virtual Machine having Ubuntu 14.04 cloud image to install bind DNS server. Currently I am able to SSH into it using:
ssh.connect( hostname = dns_ip , username = "ec2-user", pkey = k )
I am also able to edit/create files in the /tmp
directory using:
stdin, stdout, stderr = ssh.exec_command("cat >> /tmp/named.conf.local")
stdin.write('key ' + domain +'. {\n')
stdin.flush()
stdin.write('algorithm "HMAC-MD5";\n')
stdin.channel.shutdown_write()
However I am unable to do the same in the /etc
directory. I have tried:
Changing the file permissions using :
channel = ssh.invoke_shell() channel.send("sudo chmod 755 /etc/bind/named.conf.local")
Generating a script in the remote VM to do the same task
- Copying the file from the server to the remote directory
It seems that I cant change the file permissions necessary to write to it and the image I am using does not have a password (I can only access it via key file). Please help me out I have been stuck for 5 hours