ssh user@IP -> enter 'yes', give a combined command of scp and sshpass for it. +1 for suggesting an alternative but can we avoid supplying password on command line? Is there a more modern version of "Acme", as a common, generic company name? 2nd screen will be in the background as extra "terminal window". +1 for your answer but question was about doing it without public/private keys. The problems here is that it exposes your password in plain text in the file as well as in the command history. SSH to multiple server and then sftp and copy the file to a server? Create a shell script named input.sh and add following content. What tool do I need in order to remove these pedals? How to travel to this tower with a gorgeous view toward Mount Fuji? Is a comment aligned with the element being commented a good practice? Add /f switch to the command. Set execute permission on your script using chmod command : chmod +x script-name-here.sh; To run your script :./script-name-here.sh Another option is as follows to execute shell script: sh script-name-here.sh OR bash script-name-here.sh; Let us see script examples and usage in details. How to select outermost vertices in a shape like this? How to reload .bash_profile from the command line? In a collision shouldn't objects of different mass have same acceleration? You can use lftp interactively in a shell script so the password not saved in .bash_history or similar by doing the following: And write/quit the vi editor after you edit the host, user, pass, and directory for your put file typing :wq .Then make your script executable chmod +x test_script.sh and execute it ./test_script.sh. hi, i want to execute a shell script as a different user. I'm running a shell script using terminal from userA.In the middle of this shell script, I switch to userB user using su, but this asks me for the password of userB and I have to manually enter the password through terminal. Are there examples of finite-dimensional complex non-semisimple non-commutative symmetric Frobenius algebras? How do a transform simple object to have a concave shape. I have the script's owner set as root. Security says only run within a browser and its access to commands and filesystem is limited. How to specify the private SSH-key to use when executing shell command on Git? I wonder if I were to add this to my environment variable as alias or a function, would it be secure and possible to hide it from other users? Can I connect to running autostart python script? I'm asking if there is a way so that I can enter the password automatically without having me to stay beside the machine to manually enter the password? If the executable you want to run is only executable by one particular user, that's fine too - just pass that username in the sudo -u username commandline line of the script. How to Run Shell Scripts with Sudo Command in Linux Aaron Kili October 30, 2017 October 30, 2017 Categories Linux Commands 4 Comments sudo is a powerful command line tool that enables a “ permitted user ” to run a command as another user (the superuser by default), as defined by a security policy. https://superuser.com/questions/476709/quickly-switching-between-virtual-sessions-screen, State of the Stack: a new quarterly update on community and product, Podcast 320: Covid vaccine websites are frustrating. More: https://superuser.com/questions/476709/quickly-switching-between-virtual-sessions-screen. Ask Ubuntu works best with JavaScript enabled, Start here for a quick overview of the site, Detailed answers to any questions you might have, Discuss the workings and policies of this site, Learn more about Stack Overflow the company, Learn more about hiring developers or posting ads with us, What if I for example need to run 2 scipts and then I want to run. The question is about using a password authentication, not a public key authentication. I can do this for one command (e.g. If that is not what you are after, please be more specific in your question. Stack Exchange network consists of 176 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. the flow is like this. If you set it to "Run whether user is logged on or not" it will hide the command window. Run command for opening remote desktop session in full screen mode. ctrl+a, c will create a new "window" in your active screen session. rev 2021.3.12.38768, Stack Overflow works best with JavaScript enabled, Where developers & technologists share private knowledge with coworkers, Programming & related technical career opportunities, Recruit tech talent & build your employer brand, Reach developers & technologists worldwide. If you start your script with root permissions but need to run certain commands as a specific non-root user you can use sudo with the -u option to either run a single command with e.g. Please, a minor question: I am trying to use your script with my own program (calling a .lnk file that executes a Windows shell .exe), and I can not set my preferred icon, as I always do with any .lnk file.This is: the icon gets assigned to the .lnk, but during the execution (after accepting UAC prompt) the running window has the usual CMD icon. Below are the steps. Ask Ubuntu is a question and answer site for Ubuntu users and developers. if the script has print statements, will those be displayed on my terminal? However this will require you to pass the password on command line and anybody on the system doing. Should we ask ambiguous questions on an exam? To overwrite existing file, add "set xfer:clobber on" after lftp<