SSH without the command

I recently stumbled upon some old notes from some years ago that referred to being able to enter just a hostname at a shell prompt ( I think it was tcsh ) and have an ssh connection to that host established without further ado. Yes one had to enter a password, but that was no problem. I believe it had to be set up in the shell somehow, but I cannot get the memory back about how. As I recall it was quite convenient. Now I am trying to figure out how to do it and cannot seem to find an incantation to make it happen. I have looked quite widely for it, and either I am not looking in the right places, or else not for the right thing. Does anyone here remember doing that and if so can you remember how? Even just a pointer to the proper direction would be helpful.

Not sure if this belongs here or under scripting. If wrong, please feel free to move it or point me to where it should be.

Thanks,
QG
 
I think you're looking for ssh with private key.
You can google on that and find several posts on how to achieve that.
Your private key may or may not have a password.
Remember that if you don't type the username like username@hostname it will assume the same user of your session and that username must exist in the remote system too where the ssh key is stored.
 
“Computer: Do as I think.” As far as I know, you need to know in advance what are legal host names, and what strings shall cause a command not found error (consider a mere spelling mistake in a command name).​
Bash:
# NB: Not _all_ hosts necessarily have sshd running.
getent hosts | while read -r address hostnames
do
	for hostname in ${hostnames}
	do
		type ${hostname} > /dev/null || alias ${hostname}="ssh ${hostname}"
	done
done
If you want to tell your DNS server which misspelled commands you were executing, in bash(1) and zsh(1) you may define your own command_not_found_handler shell function that is executed whenever a command isn’t found; maybe tcsh(1) has something similar.​
Bash:
command_not_found_handler() {
	exec ssh "${@}"
}
 
being able to enter just a hostname at a shell prompt
in this case if you're not even typing the ssh command it should be a script or an alias, I believe it's really an alias you're looking for
alias remotehost="ssh remotehost"

you can add that to the .profile script at home path.
 
“Computer: Do as I think.” As far as I know, you need to know in advance what are legal host names, and what strings shall cause a command not found error (consider a mere spelling mistake in a command name).​
Bash:
# NB: Not _all_ hosts necessarily have sshd running.
getent hosts | while read -r address hostnames
do
    for hostname in ${hostnames}
    do
        type ${hostname} > /dev/null || alias ${hostname}="ssh ${hostname}"
    done
done
If you want to tell your DNS server which misspelled commands you were executing, in bash(1) and zsh(1) you may define your own command_not_found_handler shell function that is executed whenever a command isn’t found; maybe tcsh(1) has something similar.​
Bash:
command_not_found_handler() {
    exec ssh "${@}"
}
that looks nice
 
Not really sure what you were trying, but I use x11/xdotool to login without prompting. It's pushing characters in the Xorg keyboard buffer, so you need time delays to skip processing time. It might require more time on slower computers.
This is 1 script I use, where the user password is 1234 and also for the following su - command:
Code:
#!/usr/local/bin/bash

sleep .4 && xdotool key y e s enter &
sleep .6 && xdotool key 1 2 3 4 enter &
sleep .8 && xdotool key s u space minus enter &
sleep 1 && xdotool key 1 2 3 4 enter &
essh user@192.168.1.100

Ofcourse, this way has obvious security risks. Don't have such scripts readable for normal users. It contains the root password.
 
Back
Top