I'm following this tutorial SSH Tutorial for Linux

I've manually transfered the public key to the remote server and I ran these commands also because it wasn't asking me for my passphrase.

chmod 700 ~/.ssh &
chmod 600 ~/.ssh/authorized_keys

But still it doesn't ask me for my passphrase. I tried the newer automatic way to install the public key ssh-copy-id -p 2222 yourusername@your.website.com and got this error message:

Bad port 'umask 077; test -d ~/.ssh || mkdir ~/.ssh ; cat >> ~/.ssh/authorized_keys && (test -x /sbin/restorecon && /sbin/restorecon ~/.ssh ~/.ssh/authorized_keys >/dev/null 2>&1 || true)'

Is this error because I've already transferred it manually?

I ran ssh login with -v these are the mentions of public key:**

debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering DSA public key: /home/localusername/.ssh/id_dsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/localusername/.ssh/id_rsa
debug1: Trying private key: /home/localusername/.ssh/id_ecdsa
debug1: Next authentication method: keyboard-interactive

I'll note this is prior to logging in.

  • have you tried ssh-copy-id -i ~/.ssh/id_rsa.pub user@remotehost -p2222 Also scp for example uses P capital letter to specify a remote port. Nov 8, 2013 at 20:03

1 Answer 1


I think those errors are because the ssh-copy-id script doesn't appear to be able to handle the -p switch for a different port.

This is the line out of my version of that script:

{ eval "$GET_ID" ; } | ssh $1 "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys; test -x /sbin/restorecon && /sbi
n/restorecon .ssh .ssh/authorized_keys" || exit 1

Notice there isn't any arguments being passed into ssh-copy-id that would incorporate the -p 2222 argument. At least not as the 1st argument to ssh-copy-id as you're attempting to use it. The usage is shown as this:

$ ssh-copy-id -h
Usage: /usr/bin/ssh-copy-id [-i [identity_file]] [user@]machine

Rather you'll need to do the copying of the keys manually, unfortunately if you're using a script like mine (on Fedora 14) when attempting to copy to a host on a non-standard port, such as -p 2222.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.