Monday, September 9, 2013

sftp connection via non-standard port and Identity file

-bash-3.00$ sftp -oPort=5722 sftpuser@sftpfoobar-example.com

Connecting to -sftpfoobar-example...
The authenticity of host 'sftpfoobar-example.com (195.246.229.39)' can't be established.
RSA key fingerprint is 0b:1a:e7:6d:56:5b:ec:6f:999:5a:5b:ca:28:20:df.
Are you sure you want to continue connecting (yes/no)? ^C

Second way is using an identity file. This is in case you are connecting the server out of your domain and the same key dosen't work for all. In this case get the ssh-keygen -t rsa generate the key specific to the hostname.

[root@RHEL-6 ~]# ssh-keygen  -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /home/suser/.ssh/id_rsa_cluster1
Enter passphrase (empty for no passphrase):


provide the passphrase to add second security layer.

You can pass this option to the command - Now provide the passphrase and you should get the sftp prompt.

sftp -o Port=6022 -o IdentityFile=/home/suser/.ssh/id_rsa.pub sftpuser@sftpfoobar-example.com