stty: tcgetattr: A specified file does not support the ioctl system call.

Hi,

I am trying to implement SSH between two systems say ukblx151 & ukapx047 with ID say khzs228, i follow the following process:

Step-1) $ ssh-keygen -t rsa -f rsa
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in rsa.
Your public key has been saved in rsa.pub.
The key fingerprint is:
5c:cb:fb:ec:87:a2:0e:92:a4:bd:e7:8f:99:1b:5c:50 khzs228@ukblx151

Step-2) $ cat rsa.pub | ssh khzs228@ukapx047 `cat - >> /home/khzs228/.ssh/authorized_keys`
Pseudo-terminal will not be allocated because stdin is not a terminal.
khzs228@ukapx047's password:
stty: tcgetattr: A specified file does not support the ioctl system call.

I get the above error (i.e. stty:tcgetattr: A specified file does not support the ioctl system call.), can anybody help?

Regards,
Vishal

may be related to

The "cat ssh.pub | ssh" part means that ssh got a pipe as stdin which is not a terminal. Hence it did not allocate a pseudo-terminal, as it's not a terminal tcgetattr() is not going to work.

Porter,
Can you explain a bit in detail?

A normal process has three default file descriptors, these are stdin, stdout and stderr and normally attached to a terminal.

IO redirection replaces some of these connections with pipes.

A file descriptor attached to a terminal will respond to tcgetattr, one attached to a pipe will not.

Your "cat ssh.pub | ...." replaced stdin with a pipe......

thanks a lot Porter

Hi Porter/All,

I just tried one thing, i used "'" instead of "`" in cat rsa.pub | ssh khzs228@ukapx047 `cat - >> /home/khzs228/.ssh/authorized_keys` command & i am very happy to tell you that it worked & the problem of stty: tcgetattr didnt appear, but issue here is when i give a command like "ssh user@destination-server.com" it again asks for user's password, & this i dont want, it shouldnt ask for password. Any ideas?

Regards,
Vishal

  1. Each user needs to generate a public and private key. This key should *not* require a password.

  2. Each user needs to add they public key to their $HOME/.ssh/authorized_keys

  3. Each user needs to provide the key on the ssh command line

If you already have an .ssh/id and .ssh/id.pub use the id.pub and ssh should pick up .ssh/id by default.

  1. Only the user on the source (local) system need to generate a key-pair. When generating this key-pair, a blank passphrase should be entered.
  2. The key has to be added to the file that is specified in your sshd_config file (this would be usually the authorized_keys or authorized_keys2 file in the $HOME/.ssh directory)
  3. Your $HOME/.ssh/<private_key> file should match the one specified in the ssh_config file as IdentityFile.
  4. The .ssh directory on both servers should have 700 permissions and should be owned by the owner of the home directory.

Dear Blow/Porter,

I think the problem was with the file permissions of may be $HOME/.ssh or the keys, I changed the file permission of $HOME/.ssh to 700 & it worked. Now its not asking for the password for the ssh user@destination.server.com command.

Thanks a lot to both of you.
Porter specially you, who kept me replying from the start. :slight_smile:

Regards,
Vishal

Thanks for letting us know when things work as well. :slight_smile: