1

I have setup SSH Local Port forwarding successfully with the below command

 ssh rex@server-001 -L 0.0.0.0:4122:node-x3:22

Now I am trying to do a passwordless access . For that I am using below command

 ssh -i /home/rex/.ssh/id_rsa rex@server-001 -L 0.0.0.0:4122:node-x3:22 

But it is asking or password. How to make passwordless work in Port forwarding.

Zama Ques
  • 523
  • 1
  • 9
  • 24
  • 1
    Is there a password on your private key or is the server not accepting your key and asking for a password instead? check from your client with one or `-v` debug switches or look at the server logs. – HBruijn May 24 '18 at 07:12
  • I am able to resolve the issue. It seems we have setup the passwordless access on the server itself from where I am firing the `ssh` command rather than on the destination server for local port forwarding to work . – Zama Ques May 24 '18 at 13:35

1 Answers1

2

You need to authorize the key on the target host. You can do this manually (by putting the public part of the key in $HOME/.ssh/authorized_keys) or by using the ssh-copy-id helper program.

ssh-copy-id -i $HOME/.ssh/id_rsa.pub rex@server-001

If you do it manually, you'll need to check the permissions on the .ssh directory and the authorized_keys file - see the man page for more details but, as a general rule, it should be:

drwx------ .ssh
-rw------- .ssh/authorized_keys

If that doesn't work, add a -v (for verbose) to the ssh command used to log in and see what it's complaining about.

foo
  • 76
  • 5