How to Connect to a Remote Server with Ssh in R

how do you connect to a remote server with ssh in R

There is direct support for ssh/scp in RCurl:

x = scp("remote.ssh.host.com", "/home/dir/file.txt", "My.SCP.Passphrase", user="username")

Connect to a server by R (with cmd.exe)

If anybody has the same question in the future:

You have to write

telnet adress.net Portnumber

into cmd.exe. After that you can log in. But

system(command = "telnet adress.net Portnumber")
shell(cmd = "telnet adress.net Portnumber")

did not both not work so i used following function:

con <- socketConnection("adress.net", port = Portnumber, server=FALSE, open="r+b")
writeLines("Username\r", con)
writeLines("Password\r", con)

With that, you are good to go without cmd.exe

The output is not displayed correctly formatted when i get output with ssh connection remotely with python script

By default data in s.before is of bytes, not str. You can decode when printing:

print(s.before.decode() )

You can ask it to automatically convert the data to str by specifying an encoding:

s = pxssh.pxssh(encoding='utf8')
...
print(s.before)


Related Topics



Leave a reply



Submit