[SOLVED] Script question: Shell script in kde to log in on a server with ssh
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
First and probably biggest problem I see: You cannot give the ssh command a password with an option (-i is used for something else, there is no option to supply the password). You need to give it by hand or set up ssh to use password-less log in.
Ok I tried it before and it worked, but now it doesn't work anymore, so I guess you are right
So then my code would be:
Code:
username=`eval whoami`
password=`kdialog --title "Log in " --password "Enter password:"`
server="servername_or_ip"
ssh -XC $username@$server
Something to give enter the password
Ssh to use password-less log in is impossible. I do not have root access.
username=`eval whoami`
password=`kdialog --title "Log in " --password "Enter password:"`
server="servername_or_ip"
ssh -XC $username@$server
Something to give enter the password
The bold parts are not needed:
- the whoami command doesn't need to be evaluated,
- the password dialogue has no use,
- ssh will ask for the password, no need to do anything extra.
errorcode.
It's like the script doesn't detect ssh -XC $username@$server as a command.
Do I need to add something to the script like "#! /bin/csh -f" or something else?
The problem is I may not set up the server for password-less login. Its at my work. I can't change anything to the configuration. So we'll have to do it by entering the password in the console.
- exile is the name of one of my servers, substitute it with the valid hostname (or IP) of the machine you want to connect to,
- I do get a message about the -X option, but is is not a show-stopper. You might or might not need the -XC flags.
- exile is the name of one of my servers, substitute it with the valid hostname (or IP) of the machine you want to connect to,
- I do get a message about the -X option, but is is not a show-stopper. You might or might not need the -XC flags.
./kdialog.sh: Command not found. This tells you the script is not found in the directory you are standing in (bash cannot find kdialog.sh). Use the full path to run the script or cd into the directory were kdialog.sh is.
Just in case, can you post the output of file kdialog.sh and od -c kdialog.sh
./kdialog.sh: Command not found. This tells you the script is not found in the directory you are standing in (bash cannot find kdialog.sh). Use the full path to run the script or cd into the directory were kdialog.sh is.
Just in case, can you post the output of file kdialog.sh and od -c kdialog.sh
Hope this helps.
file kdialog.sh
Quote:
kdialog.sh: Bourne-Again shell script text
od -c kdialog.sh
Code:
0000000 # ! / b i n / b a s h \r \n u s e
0000020 r n a m e = ` w h o a m i ` \r \n
0000040 s e r v e r = " t p i " \r \n s s
0000060 h $ u s e r n a m e @ $ s e r
0000100 v e r
0000103
Btw: I'm in the directory the script is in when I execute it.
The output of the od command tells me that the kdialog.sh is not a normal linux file. The file terminator is wrong, \r \n => indicates a dos/windows file. \n \n would point to a linux file. That is why your script won't execute.
The output of the od command tells me that the kdialog.sh is not a normal linux file. The file terminator is wrong, \r \n => indicates a dos/windows file. \n \n would point to a linux file. That is why your script won't execute.
How are you creating the script?
Hope this helps.
Ok the puzzle starts to fall together
I copied the code from my windows pc in a text file and copied that code into a file on my Linux pc.
So if I create a new file and I type it over it should work I hope.
I'll keep you posted!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.