Code Monkey home page Code Monkey logo

Comments (3)

t-cas avatar t-cas commented on August 19, 2024

Hello @Yasinmohammed007,

to overwrite /etc/resolv.conf file you generally need root permissions.

If you current user is already root, you don't need use_sudo as you are already root it should work fine.

Here, I guess that's not the case for you, so you need to set use_sudo=True.
Then depending on the setup of the remote server, it may indeed request a password, this is unfortunately not supported today by jumpssh file method.

As a workaround, and if you already have root access on the remote server, you can manually disable sudo password this remote server by editing sudoers file with sudo visudo and using this line for your user:
your_username ALL=(ALL) NOPASSWD:ALL, it will unblock your issue.

from jumpssh.

Yasinmohammed007 avatar Yasinmohammed007 commented on August 19, 2024

Hi @t-cas Thibaud, Thanks for replying on this.

Exactly, as you said, i Don't have root access, your suggestion is good.
"your_username ALL=(ALL) NOPASSWD:ALL" , But i dont want to do it.

How ever i've got the answer that JumpSSH doesn't support this passing password Feature.

Would like to know, If Dev Team would consider this and add this feature to the code. Any idea what other modules i can use to solve the problem i've quoted.

from jumpssh.

t-cas avatar t-cas commented on August 19, 2024

In fact, after a bit more thinking, this behavior is already supported in jumpssh but on the more generic run_cmd method, so you can do it with jumpssh, it will just require an additional command.
Something like the following should work:

# create file in temporary path
gateway_session.file('/tmp/resolv.conf', content='nameserver 10.220.220.228')

# move it in final destination, send sudo password when needed
gateway_session.run_cmd(
  'sudo mv /tmp/resolv.conf /etc/resolv.conf',
  input_data={'password': '<sudo_password_here>'},
)

Note that you may need to adjust the key of input_data dictionary to match what is displayed when sudo password is requested.

This is clearly a feature that could be added directly as part of file method to avoid this extra steps, I will create a dedicated ticket for that.

Tell me if it works fine for you.

from jumpssh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.