Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to specify remote scp username #8

Closed
wmccracken opened this issue Feb 6, 2021 · 6 comments
Closed

How to specify remote scp username #8

wmccracken opened this issue Feb 6, 2021 · 6 comments

Comments

@wmccracken
Copy link

Hello,

I was wondering how to specify the username of the remote user when using scp with LocalhostKeyAuth. It appears to try and connect as the user that is running the program (USER from env). I tried modifying the url to scp://user@host:22/path/to/file but that does not work.

Thanks!

-Will

@adranwit
Copy link
Collaborator

adranwit commented Feb 7, 2021

Credenitals are supplied as options, to use user/passwor use the following:

auth := scp.NewAuthProvider(nil, option.NewBasicAuth("myuser", "password"))
data, err := fs.DownloadWithURL(context.Background(), "scp://127.0.0.1/etc/hosts", auth)

@wmccracken
Copy link
Author

wmccracken commented Feb 7, 2021 via email

@adranwit
Copy link
Collaborator

adranwit commented Feb 7, 2021

auth := scp.NewAuthProvider(nil, option.NewBasicAuth("myuser", "password"))
this should use only basic auth, thus no ssh keys are needed,

@adranwit
Copy link
Collaborator

adranwit commented Feb 7, 2021

SSH auth supported methods:

https://github.com/viant/afs/blob/master/scp/auth.go

@adranwit
Copy link
Collaborator

adranwit commented Feb 7, 2021

auth := scp.NewAuthProvider(scp.NewKeyAuth(path.Join(os.Getenv("HOME"), ".ssh", "id_rsa"), "myuser", "optional_password_for_pem_file_leave_empty_otherwise"), nil)
data, err := fs.DownloadWithURL(context.Background(), "scp://127.0.0.1/etc/hosts", auth)

@wmccracken
Copy link
Author

Thank you!

@adranwit adranwit closed this as completed Feb 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants