The machine which run the ssh command is the client
The machine that the client access using ssh is the server
- Run the following command on the client
- -> ssh-keygen -t dsa
- File id_dsa and id_dsa.pub will be created inside $HOME/.ssh
- Copy id_dsa.pub to the server's .ssh directory
- -> scp $HOME/.ssh/id_dsa.pub user@server:/home/user/.ssh
- Change to /root/.ssh and create file authorized_keys containing id_dsa content
- -> cd /home/user/.ssh
- -> cat id_dsa >> authorized_keys
- Change "StrictModes yes" in /etc/ssh/sshd_config to "StrictModes no"
- Restart ssh server
- You can try ssh to the server from the client and no password will be needed
- -> ssh user@server
- Run the following command on the client
- -> ssh-keygen -t dsa
- File id_dsa and id_dsa.pub will be created inside $HOME/.ssh
- Copy the id_dsa.pub to the server's .ssh directory
- -> ssh-copy-id -i ~/.ssh/id_dsa.pub user@server
- Change "StrictModes yes" in /etc/ssh/sshd_config to "StrictModes no"
- Restart ssh server
- You can try ssh to the server from the client and no password will be needed
- -> ssh user@server
Wonderful. I've been searching for this for several days. Clear and easy to understand. Thanks.
ReplyDeleteAwesome! Straight to the point! Thanks!
ReplyDeleteHi, I tried the same thing but it doesn't seem to work on RedHat linux... it is still asking me for the password. Do I have to change the configuration or permissions somewhere for this to work?
ReplyDeleteHi sjoshi,
ReplyDeleteThis method was tested on CentOS, which can be regarded as Redhat Linux's twin. You can try restarting the server's sshd, if following the method still fails. Thanks
Should the name of the file in remoteserver .ssh/authorized_keys.
ReplyDeleteIs there anyway to configure the file name?
#!/usr/bin/expect -f
ReplyDeleteif { [llength $argv] < 3 } {
send "Usage: ssh2 \n"
exit;
}
set host [lrange $argv 0 0]
set user [lrange $argv 1 1]
set pass [lrange $argv 2 2]
set supass [lrange $argv 3 3]
set timeout -1
spawn ssh $user@$host
match_max 100000
expect {
"*yes/no*" {
send -- "yes\r"
exp_continue
}
"*?assword:*" {
send -- "$pass\r"
}
}
interact
how do i ssh myself without password
ReplyDeletehttps://access.redhat.com/knowledge/solutions/8761
ReplyDeletehttps://access.redhat.com/knowledge/solutions/8761
ReplyDelete"Change "StrictModes yes" in /etc/ssh/sshd_config to "StrictModes no" -- thank you -- that's what I need! I've lost half an hour trying to make ssh auth work.
ReplyDelete