Connecting To SFTP With Go

Simple and insecure way to connect to SFTP server.

·

1 min read

My application needs to retrieve data files from remote SFTP server at regular interval. Sometime the files are not available at agreed time. So I need to monitor file availability and notify the person in charge. I wrote a Go script to check those files. Execution of this script and sending notifications is handled by Monit. If you like me to write about Monit, let me know in the comment.

Host Key Verification

HostKeyCallback: ssh.InsecureIgnoreHostKey() HostKeyCallback is a required attribute. The callback function should return nil if host key is accepted, or error to reject it. This article provides a method for verifying host key using "known_hosts" file.

InsecureIgnoreHostKey is used for convenience sake. It trust all host keys without any sort of verification.

Further Reading