ssh with password
I want to make a crontab that connects via ssh to a host with login and password that I desire, could you please help ?
Thank you in advance,
This should help. It is best to setup passphrases and then add to ssh-agent. Once setup then you login with username and passphrase is automatically sent from the ssh-agent tool.
There are two ways to do what you want. One involves a stored password, and one does not. Both are non-interactive, meaning that they can work when you're not there to enter a password.
The way that does not require a password. You can use public/private key authentication instead of passwords with SSH. I'm going to assume that you're using OpenSSH, which comes with practically every Linux distribution that there is.
If you think somebody has a copy of your id_rsa file, you can delete the line that you added to authorized_keys on the server, to disable that key.
FURTHER READING (Daniel Robbins at ibm.com)
If you thought that was complicated, you wait till you've tried to get this one working. The basic idea is to use expect, which is an administration automation tool, to type your password in to ssh when prompted. It might not always work, and when it doesn't, it's hard to figure out why not. I recommend the first method.
Anyway, here's a command that you can poke at until it does what you want:
Problem here is doing the scripting. You can either have expect type in further commands, or you can list them as a parameter to ssh in that spawn command (just before the semicolon ; ). It might never work properly for you; again, I recommend the first method.
FURTHER READING (various at nist.gov)
If you have any trouble, always ask. Losing the ssh server on a computer that's far away due to a typo is really, really annoying. Do back up any files you modify, preferably before you modify them.
I want to push my ssh public key to 350 servers. For that I need to create a directory in my $HOME/.ssh2 and scp my keys from the central login server to these servers through the script.
Can expect be used to create that remote directory and scp files to the servers also ?
As we say in Sweden... Tusen Tack!
File permissions for authorized_keys
Don't forget -
authorized_keys must possess proper Unix permissions!
chmod 600 ~/.ssh/authorized_keys
If the authorized_keys or authorized_keys2 file has the incorrect permissions it will not authenticate with your ssh-rsa key but instead still require a password. If you are having trouble configuring SSH keys you should check the /var/log/secure file to see if there is an error displaying in that log. You may see the error displayed below.
Error: Authentication refused: bad ownership or modes for file .ssh/authorized_keys
If you see this error it means that the authorized_keys or authorized_keys2 file has the incorrect ownership or permissions. Make sure that the authorized_keys file is owned by the user that will be logged into and the permissions are 600. So if the username is backup you would want the file to look like the below when issuing the “ls -alh” command.
1 -rw------- 1 backup backup 409 Mar 23 19:56 authorized_keys
Hey all, this is late but I just had to get this in there for future readers...
This is a basic RHCT level command...
|All times are GMT -5. The time now is 07:50 AM.|