I have this bash file, which asks for IP, password, etc. for OpenSSH to a device.
Now, if i use ssh root@ip
, i have to enter the password. This is really irritating. Secondly; i cannot let my script send commands to it.
This is what i want->
Not the password thing; i already found something; but it tells me the commands are not found?:
#!/usr/bin/expect -f
spawn ssh root@$IPADDR
expect "password:"
sleep 1
send "$rpass\r"
I want the user to be able to see some menus where it can choose from; after that; every command is done for him. So like a new window, or something like that?
I do not want to use: -Any external stuff -No extra editing of the SSH connection
BASH INFO: GNU Bash, v. 4.0.33(1)-release (i486-pc-linux-gnu), running on Linux Mint. But it got to be available for several linux distro's, and also on Mac?
Bash script SSH is a common tool for Linux users. It is needed when you want to run a command from a local server or a Linux workstation. SSH is also used to access local Bash scripts from a local or remote server.
The proper way to do this without storing passwords in plaintext on your machine is with ssh. First run:
ssh-keygen
This will generate a new SSH key in ~/.ssh/id_rsa.pub
. After that simply run:
ssh-copy-id [email protected]
If you're on OS X or another machine that does not have "ssh-copy-id" there are one-line alternatives such as this one:
cat ~/.ssh/id_rsa.pub | ssh user@machine "mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"
Ultimately you just need to append the contents of ~/.ssh/id_rsa.pub
on your local machine to ~/.ssh/authorized_keys
on the remote server. How you do that is up to you, the above are just quick shortcuts to do that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With